aspose file tools*
The moose likes Beginning Java and the fly likes Jar file problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Jar file problems" Watch "Jar file problems" New topic
Author

Jar file problems

Ryan Sampson
Greenhorn

Joined: Jan 11, 2004
Posts: 12
ok, so i finally figured out ant and used it to compile and build a jar file. However, when i try to run the jar file, i get the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: com/jgoodies/plaf/plastic/PlasticTheme

The class causing the error is an external jar file my program depends on.
Its called jgoodies.jar (skins the GUI) which i import in my source code. I also added it to the class path when i compiled. I used ant to include it in the final program jar, so its there. Yet when i run this jar it says the class path isnt set for it. It cant find it. Can you have jar files inside of jar files? Am i suppose to add more to the manifest file? I allready have it pointing to the class containing my main and thats working.

How do i include my external library jars my program depends on inside the final executable jar for my program so it can find them?

This is driving me crazy, first i had a hell of a time with ant, now this... Why does deployng your program have to be so complicated in java.. =(

Thanks, ryan
Sonny Gill
Ranch Hand

Joined: Feb 02, 2002
Posts: 1211

AFAIK you can have a jar file in another jar file, but Java Runtime wont be able to find it, so it is no use.

It is common practice to include the other jars needed by your program in the classpath when invoking java runtime. To make it easier you could write a simple batch script that sets the classpath properly and then invokes java with your application.

But if you really must have a single jar, you could unjar the other library to get the classes, and then jar it again, this time including your classes.

HTH
Sonny
Ryan Sampson
Greenhorn

Joined: Jan 11, 2004
Posts: 12
Thanks Sonny, i figured it out. What i did was add a Class-Path attribute in the manifest file..

Class-Path: looks-1.1.3.jar formsrt.jar lib\

That did the job. Of course the jars have to be external like you said, but thats not a problem..

What a relief, finally got ant down, and i now know how to deploy my game.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Jar file problems
 
Similar Threads
problem in loading .dll file using web start?
Jar files...dont know what is the problem
Exporting to jar file in eclipse
Reading external files from a jar
ANT classpath