2012-12-20 106 views
0

我創建一個桌面應用程序使用swing和spring的一些東西。一切都很順利,但是當我使用eclipse JUNO創建jar時,我得到了這個錯誤,試圖運行它爲java -jar myjar.jar on cmd。我不知道問題出在哪裏,有什麼幫助?錯誤:noclassdeffounderror在jar執行

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/springframework/context/ApplicationContext 
     at efact.alfa1lab.nazca.jframe.NazcaLogin.<init>(NazcaLogin.java:145) 
     at efact.alfa1lab.nazca.jframe.NazcaLogin$1.run(NazcaLogin.java:97) 
     at java.awt.event.InvocationEvent.dispatch(Unknown Source) 
     at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 
     at java.awt.EventQueue.access$000(Unknown Source) 
     at java.awt.EventQueue$3.run(Unknown Source) 
     at java.awt.EventQueue$3.run(Unknown Source) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) 
     at java.awt.EventQueue.dispatchEvent(Unknown Source) 
     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) 
     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) 
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) 
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 
     at java.awt.EventDispatchThread.run(Unknown Source) 
Caused by: java.lang.ClassNotFoundException: org.springframework.context.ApplicationContext 
     at java.net.URLClassLoader$1.run(Unknown Source) 
     at java.net.URLClassLoader$1.run(Unknown Source) 
     at java.security.AccessController.doPrivileged(Native Method) 
     at java.net.URLClassLoader.findClass(Unknown Source) 
     at java.lang.ClassLoader.loadClass(Unknown Source) 
     at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) 
     at java.lang.ClassLoader.loadClass(Unknown Source) 
     ... 16 more 

這是我的文件夾結構

- myclasses 
- images 
- lib 
- META-INF 
+ MANIFEST.MF 
    - applicationContext.xml 
- build.xml 

這是我MANIFEST.MF所有春瓶,包括:彈簧上下文支持,3.2.0.M1.jar彈簧上下文3.2.0.M1.jar

Manifest-Version: 1.0 
Class-Path: lib/swingx-1.6.1.jar lib/spring-aop-3.2.0.M1.jar lib/spring-context-support-3.2.0.M1.jar lib/spring-context-3.2.0.M1.jar 
    lib/javadbf-0.4.0.jar lib/log4j-1.2.16.jar lib/spring-asm-3.2.0.M1.jar lib/spring-beans-3.2.0.M1.jar 
    lib/spring-core-3.2.0.M1.jar lib/spring-expression-3.2.0.M1.jar lib/spring-orm-3.2.0.M1.jar 
    lib/spring-oxm-3.2.0.M1.jar lib/spring-test-3.2.0.M1.jar lib/spring-tx-3.2.0.M1.jar lib/spring-web-3.2.0.M1.jar 
    lib/spring-webmvc-3.0.5.RELEASE.jar lib/spring-webmvc-3.2.0.M1.jar lib/spring-ws-1.5.9-all.jar lib/troughoasis.jar 
    lib/commons-lang-2.3.jar lib/commons-logging-1.1.1.jar lib/concar.jar lib/ini4j-0.5.2-SNAPSHOT.jar 
Main-Class: com.mycompany.MainClass 

回答

0

的中的210指令不能按預期工作。我建議您使用One-JAR結合Ant或Maven將應用程序及其所有依賴項打包到單個JAR中。我一直在使用這種方法,因爲上帝知道多久 - 完美無瑕。