Josh
Josh

Reputation: 83

Java command line launcher

So I'm trying to launch a jar from the command line using these arguments similar to these:

java -cp "path/test.jar;path/lib.jar" -Djava.library.path="path/another_lib.jar" net.test.Test

(net.test.Test is the main class) Which gives me a NoClassDefFoundError Exception (for net/test/Test).

This seems to work fine for other people, so I'm not sure why it isn't working.

Upvotes: 1

Views: 365

Answers (1)

Ernest Friedman-Hill
Ernest Friedman-Hill

Reputation: 81674

First, -Djava.library.path=/something tells the JVM where to find native libraries -- i.e., DLLs. It has nothing to do with finding jar files, so if you're using that flag to locate jar files, that's going to be a problem right there.

Otherwise, this is fine. You need to make sure all of those paths are correct, and the jar file containing net.test.Test really does contain the class in question, and inside the jar file the Test.class file is in a test directory in a net directory.

As Rup points out in a comment, if there are any classes in your current directory that you need to pick up, you'll want to add an entry for ".", the current directory, to the -cp argument.

Upvotes: 3

Related Questions