Link to home
Start Free TrialLog in
Avatar of nkan
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.
Avatar of boonleng
boonleng
Flag of Malaysia image

You can put a jar file inside another jar file.

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
ASKER CERTIFIED SOLUTION
Avatar of boonleng
boonleng
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of apparition
apparition

Try

java -cp one.jar;myjar.jar