This discussion is archived
1 Reply Latest reply: Apr 24, 2010 3:59 AM by baftos RSS

Loading JAR files from manifest Class-Path header causes errors

843804 Newbie
Currently Being Moderated
Let's say I have 3 class files: Main.class, A.class, B.class. Now A.class has some dependencies located in a JAR file called tools.jar i.e. has some import statement referencing a class in tools.jar.

The class files are located at C:\Test and the tools.jar files is located at C:\Test\lib.

I generate the JAR file by going to C:\Test and do:
jar cvfm app.jar manifest.txt *.class lib/*.jar

with the manifest.txt file looking like

Manifest-Version: 1.0
Class-Path: lib/tools.jar
Created-By: 1.6.0_18 (Sun Microsystems Inc.)
Main-Class: Main

This assembly process works fine but when I execute the program from the command line with
java -jar app.jar

I get the Java.lang.ClassNotFoundException from "exp.formats.FormatException". When checking the tools.jar file there is a location called exp/formats where a FormatException.class files resides.

So why cant my Jar file locate it?

Edited by: e-blade on Apr 24, 2010 2:58 AM