• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Executable JAR help!

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've created an executable jar with the MANIFEST.MF as follows.

It executes fine. HOWEVER, I cannot get classpath to work.. I keep getting ClassNotFoundException from accessing any external classes.
My command line is
java -jar -cp jconn2.jar myparser.jar
Thanks for any help in advance. I have tried the normal method of executing the class, and it works.
[ September 06, 2002: Message edited by: Chu Tan ]
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works if I put Class-Path option in the manifest, that means I must put a copy of the dependant jar in the same directory. I'd rather not do that, if there are any alternatives.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From Understanding the Manifest:
The URLs in the Class-Path header are given relative to the URL of the JAR file of the applet or application.
I can't think of a way around that, but I can imagine a situation where it may be convenient to specify an absolute URI. (I do realize that didn't really help solve your problem.)
Good Luck.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works if I put Class-Path option in the manifest, that means I must put a copy of the dependant jar in the same directory. I'd rather not do that, if there are any alternatives.
Just to be thorough...
You don't have to put each jar in the same directory, but they do have to be in a relative directory structure. So, One.jar could be in the root directory and Other.jar could be in a subdirectory called anything. The Class-Path setting would then be specified as Class-Path: One.jar anything/Other.jar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic