简体   繁体   中英

java.lang.NoClassDefFoundError - Generating Executable Jar

I have created my JAR on Windows 2000 having java version 1.5 which contains following directories/files:

  • manifest.txt
  • com
  • lib

lib contains all JARS which I want to make part of my JAR. com contains my class files and below is manfiest.txt file

Main-Class: com.as.qst.result.ResultTriggerSchedular 
Class-Path: lib/axis.jar lib/c3p0-0.9.1.1.jar lib/commons-discovery-0.2.jar lib/commons-logging-1.0.4.jar lib/jaxrpc.jar lib/log4j-1.2.16.jar lib/medplus-hub-8.2-wsclients.jar lib/medplus-hub-13.1-jaxws-clients.jar lib/quartz-2.2.1.jar lib/quartz-jobs-2.2.1.jar lib/saaj.jar lib/slf4j-api-1.6.6.jar lib/slf4j-log4j12-1.6.6.jar lib/ wsdl4j-1.5.1.jar lib/xercesImpl.jar com\as\qst\result

I used following command to generate my JAR

  jar cvfm test.jar manifest.txt com lib

It has successfully created a JAR file but when I try to run it with

java -jar test.jar

it does not execute and throws above exception. I used the same process for Windows 7 which has version 1.7 and it did work out even without class files path in manifest.txt com\\as\\qst\\result . Is something more to do with class-path besides defining in manifest? and why is it working in Windows 7?

You do not need the class file path in your class path entry. So instead of adding com\\as\\qst\\result to your class-path .

More over you must not package other jar files in your runnable jar.

Other required jars must be provided in the same folder as your jar file (may be in separate folder) and Add current directory "." (without quotes) to your class-path .

Hope this helps.

EDIT

Just found this Stackoverflow Link . This might give you more insight. Please read through it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM