1
這裏是我的Ant目標:JAR - 例外在線程「主要」 java.lang.NoClassDefFoundError:組織/ mortbay /碼頭/處理器
<target name="jar" depends="compile">
<mkdir dir="build/jar" />
<jar destfile="build/jar/mobileAppQueuing.jar" basedir="build/classes">
<fileset dir="library" includes="*.jar" />
<manifest>
<attribute name="Main-Class" value="Main" />
</manifest>
</jar>
</target>
這裏是我,當我在冗長的啓動Ant目標模式:
> ... [javac]
> /Users/jeromeansia/git/mobileAppQueuing/MobileAppQueuing/src/model/Share.java
>
> jar:
> [mkdir] Created dir: /Users/jeromeansia/git/mobileAppQueuing/MobileAppQueuing/build/jar
> [jar] Building jar: /Users/jeromeansia/git/mobileAppQueuing/MobileAppQueuing/build/jar/mobileAppQueuing.jar
> [jar] adding directory META-INF/
> [jar] adding entry META-INF/MANIFEST.MF
> [jar] adding directory controller/
> [jar] adding directory model/
> [jar] adding entry APIHandler.class
> [jar] adding entry Main.class
> [jar] adding entry controller/CtrlShare.class
> [jar] adding entry model/Share.class
> [jar] adding entry commons-codec-1.9.jar
> [jar] adding entry commons-logging-1.2.jar
> [jar] adding entry fluent-hc-4.5.jar
> [jar] adding entry gson-2.3.1.jar
> [jar] adding entry hamcrest-core-1.3.jar
> [jar] adding entry httpclient-4.5.jar
> [jar] adding entry httpclient-cache-4.5.jar
> [jar] adding entry httpclient-win-4.5.jar
> [jar] adding entry httpcore-4.4.1.jar
> [jar] adding entry httpmime-4.5.jar
> [jar] adding entry jetty-6.1.26.jar
> [jar] adding entry jetty-util-6.1.26.jar
> [jar] adding entry jna-4.1.0.jar
> [jar] adding entry jna-platform-4.1.0.jar
> [jar] adding entry junit-4.12.jar
> [jar] adding entry mockito-all-1.9.5.jar
> [jar] adding entry scribe-1.3.2.jar
> [jar] adding entry servlet-api-2.5-20081211.jar
> [jar] adding entry twitter4j-async-4.0.3.jar
> [jar] adding entry twitter4j-core-4.0.3.jar
> [jar] adding entry twitter4j-examples-4.0.3.jar
> [jar] adding entry twitter4j-media-support-4.0.3.jar
> [jar] adding entry twitter4j-stream-4.0.3.jar
> [jar] No Implementation-Title set.No Implementation-Version set.No Implementation-Vendor set.
> [jar] Location: /Users/jeromeansia/git/mobileAppQueuing/MobileAppQueuing/build.xml:23:
>
>
> BUILD SUCCESSFUL Total time: 1 second
但是,當我啓動我罐子得到如下:
Exception in thread "main" java.lang.NoClassDefFoundError: org/mortbay/jetty/Handler
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2615)
at java.lang.Class.getMethod0(Class.java:2856)
at java.lang.Class.getMethod(Class.java:1668)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.mortbay.jetty.Handler
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
使用Eclipse生成可運行jar時,我沒有這個問題 –