Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

referencing jars from a jar

 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 -
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

This will:
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Michael Ernest
High Plains Drifter
Sheriff
Posts: 7292
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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*
 
Thomas Rochon
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 -
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic