1
我創建了一個build.xml來編譯我的源文件並創建一個jar。當我運行構建JAR被創建,但罐子以下情況例外爲構建jar創建異常
[java] Exception in thread "main" java.lang.NoClassDefFoundError: com/mysql
/jdbc/exceptions/MySQLIntegrityConstraintViolationException
構建文件是運行:
<?xml version="1.0"?>
<project name="NmzAzzist" basedir="." default="main">
<property name="src.dir" value="../Source/NMSAzzist/src" />
<property name="build.dir" value="ReleaseBuild/classes" />
<property name="jar.dir" value="ReleaseBuild/ReleaseJars" />
<path id="master-classpath">
<fileset dir="Libraries">
<include name="*.jar" />
</fileset>
</path>
<patternset id="meta.files">
<include name="**/*.xml" />
<include name="**/*.properties" />
<include name="**/*.mib" />
</patternset>
<!-- Simply extends the compile.classpath with your own compiled classes. -->
<target name="clean" description="Clean output directories">
<delete dir="${build.dir}" />
</target>
<target name="build" description="Compile source tree java files">
<echo>Compiling the source code</echo>
<mkdir dir="${build.dir}" />
<javac destdir="${build.dir}" source="1.5" target="1.5"
includeantruntime="false">
<src path="${src.dir}" />
<classpath refid="master-classpath" />
</javac>
</target>
<target name="copy.meta.files">
<copy todir="${build.dir}">
<fileset dir="${src.dir}">
<patternset refid="meta.files" />
</fileset>
</copy>
</target>
<target name="jar" depends="build, copy.meta.files">
<mkdir dir="${jar.dir}" />
<echo>building jar!</echo>
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${build.dir}">
<manifest>
<attribute name="Main-Class"
value="com.ushustech.nmsazzist.NMSAzzistApp" />
</manifest>
</jar>
</target>
<target name="run" depends="jar">
<java jar="${jar.dir}/${ant.project.name}.jar" fork="true" />
</target>
<target name="main" depends="clean,run" />
</project>
我該如何解決這個問題?
這並不解決問題。創建jar時會發生同樣的異常。 – Gapchoos
你能告訴我在類路徑中指定的文件夾中的jar名稱嗎? – Vishal
它包括用於mysql,Snmp4j和其他外部罐子的jar。這些罐子包含在ReleaseBuild/Libraries文件夾中 – Gapchoos