Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to use classpath with java -jar

807599Jan 25 2007 — edited Jan 25 2007
I have an application which is self contained in a jar files. I can start it
as follow:

java -jar application.jar

In this jar file, I have included some third party jar files that are used by my
application. When I remove one of the jar files and try to use classpath,
it does not work:

java -classpath /jardirs/Tool.jar -jar application.jar

It appears as the class path is totally ignored.
Of course, I can define Class-Path manifest in the jar file to refer to
the location of myTool.jar. However, The location could be different based on
which computer the application is run.

I am wondering if there is a solution where I can specify the location of
Tool.jar separately from application.jar, as an option in "java -jar application.jar".

Your help is greatly appreciated.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 22 2007
Added on Jan 25 2007
6 comments
350 views