Using java -jar

S

Scott Harper

If I want to run the command:

java -jar myApp.jar

does myApp.jar need to be in the $CLASSPATH, $PATH, or do I simply have to
give the fully specified path on the command line?


thanks
scott
 
D

Daniel Dyer

If I want to run the command:

java -jar myApp.jar

does myApp.jar need to be in the $CLASSPATH, $PATH, or do I simply have
to
give the fully specified path on the command line?

Your jar file needs to contain a valid manifest file that specifies the
Main-Class property. Apart from that, it's sufficient to give java the
fully qualified path.

As an aside, I always avoid using a CLASSPATH environment variable. At
best it is unnecessary and at worst it is dangerous.

Dan.
 
S

Simon Brooke

Scott said:
If I want to run the command:

java -jar myApp.jar

does myApp.jar need to be in the $CLASSPATH, $PATH, or do I simply have
to give the fully specified path on the command line?

Neither. You need to specify a valid relative or absolute path to the file,
just as if it were any other data file.

--
(e-mail address removed) (Simon Brooke) http://www.jasmine.org.uk/~simon/

((DoctorWho)ChristopherEccleston).act();
uk.co.bbc.TypecastException: actor does not want to be typecast.
[adapted from autofile on /., 31/03/05]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top