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?
posted 10 years ago
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.