aspose file tools*
The moose likes Beginning Java and the fly likes NoClassDefFoundError - Using a package in a Jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFoundError - Using a package in a Jar" Watch "NoClassDefFoundError - Using a package in a Jar" New topic
Author

NoClassDefFoundError - Using a package in a Jar

Richard Butterwood
Ranch Hand

Joined: Nov 07, 2005
Posts: 45
Hi,

I can run a jar file fine when I don't use a package, but when I add a package I get the NoClassDefFoundError. What should I be doing different when using a package?

Thanks,

Richard
Layne Lund
Ranch Hand

Joined: Dec 06, 2001
Posts: 3061
Do you know how to execute a Java program with a class inside a package when the class is NOT packaged in a JAR file? If the class is in a JAR file, it is basically the same, except that you have to make sure the JAR file is included in the classpath. For example, if you have a class named Bar in a package called foo and this class is in a JAR file called foobar.jar, then you execute it as:

This assumes that you are in the same directory as the JAR file. If not, you can specify the complete path for the JAR file after the -cp option.

Layne


Java API Documentation
The Java Tutorial
 
Consider Paul's rocket mass heater.
 
subject: NoClassDefFoundError - Using a package in a Jar