Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 725
  • Last Modified:

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.
0
nkan
Asked:
nkan
  • 2
1 Solution
 
boonlengCommented:
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
0
 
boonlengCommented:
opps..
should be You cant put a jar file inside another jar file.
0
 
apparitionCommented:
Try

java -cp one.jar;myjar.jar
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now