aspose file tools*
The moose likes Beginning Java and the fly likes Executable JAR help! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Executable JAR help!" Watch "Executable JAR help!" New topic
Author

Executable JAR help!

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
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

Joined: Apr 19, 2002
Posts: 209
    
    1
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

Joined: Dec 10, 2001
Posts: 7023
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.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Executable JAR help!
 
Similar Threads
jsp:setProperty name="" property="*" equiv for servlet
Executable jar file
Program will not run on another machine.
EAR/WAR/JAR Architecture
the pictures are not loaded into an executable jar file