错误:JAR执行中的NoclassDeffoundError



我正在使用Swing和Spring创建一个桌面应用程序。一切进展都很好,但是当我使用Eclipse Juno创建罐子时,我发现了此错误,试图以CMD上的 java -jar myjar.jar.jar.jar.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

这是我的 subtest.mf ,带有所有弹簧罐,包括: spring-context-support-3.2.0.m1.m1.jar spring-context-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

MANIFEST.MF中的Class-Path指令无法正常工作。我建议您将一Jar与Ant或Maven结合使用,将您的应用程序及其所有依赖项包装成一个罐子。我一直在使用这种方法为上帝知道多长时间 - 完美无缺。

相关内容

  • 没有找到相关文章

最新更新