david.colais
david.colais

Reputation: 619

Running jar file using classpath

I have a jar file which includes the manifest entry to the main class and I was trying to run the jar using the -jar option and then came to know that using the -jar option ignores the classpath setting.

Previous Usage: java -jar MyJar.jar

Now I have all my rest of the jars configured in $CLASSPATH.

How do I include the same while running my jar.

BTW I'm running on a Linux OS.

Upvotes: 1

Views: 265

Answers (2)

Anupam Saini
Anupam Saini

Reputation: 2421

The easy approach (provided you are familiar with ant scripts) would be to create a build script to generate an executable jar. You can define a compile rule, a rule to create an executable jar that has other jars (in exploded format) contained within it.

Please note that there is no standard way to include a jar within a jar. Classpath including JAR within a JAR

I have already done something similar here you might want to have a look the ant build file

Upvotes: 0

EJK
EJK

Reputation: 12527

java -cp $CLASSPATH -jar MyJar.jar

Upvotes: 1

Related Questions