nkan
asked on
Running a JAR file in windows cmd.
I have use WSAD 5.0 to export a jar file with main class.
When i try to use my windows cmd promt to run the jar file with the following command:
java -jar e:\myjar.jar
it can success run the main class, but when it is trying to access the class within ANOTHER jar file included in myjar.jar lib folder, I got a NoClassDefFoundError for that class.
How can I solve it?
Thanks.
When i try to use my windows cmd promt to run the jar file with the following command:
java -jar e:\myjar.jar
it can success run the main class, but when it is trying to access the class within ANOTHER jar file included in myjar.jar lib folder, I got a NoClassDefFoundError for that class.
How can I solve it?
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try
java -cp one.jar;myjar.jar
java -cp one.jar;myjar.jar
Place it outside the jar file, then set the classpath in the Manifest.mf e.g.
Manifest-Version: 1.0
Main-Class: com.test.MainClass
Class-Path: another.jar
Or place the classpath during execution
java -classpath another.jar -jar myjar.jar