This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hi folks ! There's my stupid question: I've got an application (just one class file) which I put into a jar archive. It's done by eclipse, using the export to jar function. So the manifest is also created by eclipse. My application is using some classes from another jar which I import into my application. But that's the problem. Even if I put my own jar file into the same folder where the other jars (the one I imported into my application) are, the JVM cant find them. After starting my application by double clicking my jar file, the JVM is telling me, "no class def found" (regarding the classes I imported to my app). So - What's wrong? Do I have to add a statement into the manifest? I would be very happy to hear from you. Thanx ! - Thomas -
Hi Thomas - Not a stupid question at all. Treat the name of any JAR file as a directory itself in a classpath environment. To put something called jehosophat.jar into the classpath, for example, this won't work:
Make visible what, without you, might perhaps never have been seen. - Robert Bresson
Joined: Jul 11, 2002
Hi Michael ! Thank you very much for your reply! I created a batch file in which I call my app java -jar myApp.jar Befor that I set the classpath (absolute) with: set CLASSPATH=D:/path/to/libs/ALib.jar That's the lib from which I import the needed classes into my app. But when starting the batch the JVM tells me: Exception in thread "main" java.lang.NoClassDefFoundError: iaik/pkcs/pkcs11/Module Or do I have to set the classpath into the manifest file ? Thanx! - Thomas - [ December 16, 2003: Message edited by: Thomas Rochon ]
Hi Thomas - Assuming all the needed classes are in ALib.jar and myApp.jar, and you've correctly imported everything, that should work. One way to verify this is to examine the contents of the library jar to ensure the directory structure is as you expect. All your manifest file should have to do at this point is specify the Main-Class in the myApp.jar.
Thomas, where is the iaik.pkcs.pkcs11.Module class? If it's in a JAR file in your CLASSPATH, did you check it to make sure it really is? Also, you might like to know that it's perfectly possible to put a JAR inside of another JAR when packaging applications. Take a look at the Creating an Executable JAR File thread for a simple example.
I thank all of you for your replies ! Maybe I'm a bit stupid, but after all I get the same error message as before. I set the classpath for the according jar file. I checked it with "set CLASSPATH" and my jar is shown. I also imported this jar correctly into my application, because this one is running fine inside my eclipse ide. I even packed the needed jar archive into my own jar file. But the result is always the same: "Exception in thread "main" java.lang.NoClassDefFoundError: iaik/pkcs/pkcs11/Module". *sniff*
Joined: Jul 11, 2002
I got it ... java -cp "C:\lib\iaikPkcs11Wrapper-1.2.11.jar";"C:\lib\InitToken.jar" com.whatever.pkcs11.tools.InitToken That's how I start my application, now. And it works fine. Thanks to all of you! - Thomas -