• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Specify classpath when run class in jar file

 
Bruce Jin
Ranch Hand
Posts: 672
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have application packaged in jar file and I run my class using:

> java �jar myjar.jar

How do I specify a additional classpath at run time? This command would not work:

> java �cp myclasspath �jar myjar.jar
 
Rachel Swailes
Ranch Hand
Posts: 434
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use a classpath as follows...

java -classpath c:\mypath\myjar.jar myPackage.myClassFile

(where myClassFile has the main method)

Does that help you out?
Cheers,
Rachel
 
Bruce Jin
Ranch Hand
Posts: 672
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
In my case the class is in jar file and the classpath would not work. One can put the "Class-path: xxx" in the manifest but I am wondering if there is a way to specify it at run time.
Regards
[ October 11, 2004: Message edited by: Bruce Jin ]
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't sound promising.

Clip from
java tools documentation


-jar
...
When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
untestet:

(without the -jar option, and explicitly setting the Main-Class.)
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic