jQuery in Action, 3rd edition
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NoClassDefFoundError - Using a package in a Jar" Watch "NoClassDefFoundError - Using a package in a Jar" New topic

NoClassDefFoundError - Using a package in a Jar

Richard Butterwood
Ranch Hand

Joined: Nov 07, 2005
Posts: 45

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?


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.


Java API Documentation
The Java Tutorial
I agree. Here's the link: http://aspose.com/file-tools
subject: NoClassDefFoundError - Using a package in a Jar
It's not a secret anymore!