I have an small application which has several classes. I have created a jar by combining all this classes and in the manifest file, made one of my classes as the main class. All of my classes in my jar file, use some classes from an external jar log4j.jar. I am not able to access the classes in the log4j.jar file. I get a NoClassDefFound error. Is there any way I can solve this problem without writing my own class loader? Do I need to change my manifest.mf? Sri.
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
hi, as long as u've log4j.jar in ur CLASSPATH it should work... how u r trying to use those classes? and what error you are getting?? regards maulin
Even if I keep log4j.jar in my classpath, I am getting this error. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/log4j/Logger If I write all my application in a single java file, then it is working. But the moment I use a jar file, I get the above error.
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
hi sri, well u can try one thing, in the CLASSPATH... if u've sequence, yourJAR;log4j.jar then change it to be, log4j.jar;yourJAR... sequence does matter i guess.. regards maulin
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
also, tell me how u r running ur application from command line? and the CLASSPATH setting u've.. regards maulin
Sri Nivas
Ranch Hand
Joined: Apr 18, 2001
Posts: 58
posted
0
Hello Maulin, Let me first thank you for the help and your time. I am executing my jar like this java -jar MyJar.jar My manifest.mf looks like this. Manifest-Version: 1.0 Main-Class: MyMain Classpath: lib/log4j-1.2.8.jar My classpath setting is like this: CLASSPATH=c:\jakarta-log4j-1.2.8\dist\lib\log4j-1.2.8.jar
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
posted
0
Originally posted by Sri Nivas: My manifest.mf looks like this. Manifest-Version: 1.0 Main-Class: MyMain Classpath: lib/log4j-1.2.8.jar
Classpath is the incorrect key. It should read: Class-Path: lib/log4j-1.2.8.jar And I believe that this setting overrides the system CLASSPATH, so it does not matter what that environment setting is. Hope that this helps.
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.