Monojeet Nayak
Monojeet Nayak

Reputation: 721

Putting a Jar file in ClassPath

I have a situation where extracting the jar file and then running it should start the setup for an application. This is not an application developed by me. After i extarct the jar file and try to execute it i get the following error :-

Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/swingx/JXBusyLabel

I have already downloaded the dependent jar file which has the class, however due to weak concepts on classpaths i cannot figure out how can i put the downloaded jar in the classpath.So that i can start setup of the application.

Many Thanks

Upvotes: 1

Views: 2734

Answers (2)

duffymo
duffymo

Reputation: 308733

I don't see why you should have to extract anything. Make it an executable JAR.

You'll have the CLASSPATH in your JAR manifest. See this link to learn how to set it up.

or you can just use the -classpath option on java.exe when you run to add it:

java -classpath .;jar1;jar2 <full-name-of-class-with-main-to-run>

Upvotes: 2

JB Nizet
JB Nizet

Reputation: 691625

I'm surprised that your application is not bundled with its dependencies.

Anyway, if you manage to figure out the exact dependencies it has, then put all the jars in the same directory, go to this directory, and run

java -cp firstJar.jar;secondJar.jar;lastJar.jar com.foo.bar.Main

That's on Windows. On Unix, replace the ; by :.

Upvotes: 2

Related Questions