Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAR Absolute Class-Path

 
Andy Selador
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is something that has been bugging the crap out of me to no end. (Why would they make something so essential so annoying?)

Anyways...

I have a .jar file that needs to list in its manifest class-path an absolute path to another .jar file that is on a different drive (the original .jar file will be copied and used from many locations, meaning a relative path to the other .jar will be difficult, and the other .jar MUST be on the W:\ drive to be accessed anywhere on the network). So, easy, right?

For engine.jar file containing engine\ComputeEngine.class (which is in package engine), and manifest.txt file (included using jar -cvmf manifest.txt engine.jar):

U:\src\engine.jar
- engine
- - ComputeEngine.class
- meta-inf
- - Manifest.mf

manifest.txt:

Main-Class: engine.ComputeEngine
Class-Path: W:\home\andy22286\public_html\classes\compute.jar

(The other .jar file is compute.jar.)

For some reason I get the following error (when using java -jar engine.jar in engine.jar's directory):

Exception in thread "main" java.lang.NoClassDefFoundError: engine/ComputeEngine
Caused by: java.lang.ClassNotFoundException: engine.ComputeEngine
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)

For some reason it cannot find the engine.jar.

Oh, this makes sense...

I already tried:

Class-Path: U:\src\engine.jar W:\home\andy22286\public_html\classes\compute.jar

and just about every variation in between. If I move compute.jar to the same directory and change the class-path to compute.jar, it works just fine. Unfortunately, this is not a solution (using RMI, any client must have access to compute.jar, which means two copies of the same file, one in the local directory and one on the W:\ drive, which does not seem like a good idea).

NOTE: I CANNOT use the -cp or -classpath command with -jar. -cp is ignored when using -jar.

HELP!
[ May 13, 2008: Message edited by: Andy Selador ]
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Andy Selador:
If I move compute.jar to the same directory and change the class-path to compute.jar, it works just fine. Unfortunately, this is not a solution (using RMI, any client must have access to compute.jar, which means two copies of the same file, one in the local directory and one on the W:\ drive, which does not seem like a good idea).
Let me first say that I don't know how to make your path names work, except by suggesting that you use / instead of \ and that you put another / before the drive letter. However I doubt that will fix your problem.

But what's wrong with distributing jar files to computers which need them? I don't think that's such a bad idea.
NOTE: I CANNOT use the -cp or -classpath command with -jar. -cp is ignored when using -jar.
Which suggests another solution: don't use the -jar option at all, use the -cp option only.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic