Duplicate :
|
|
Relates :
|
|
Relates :
|
Name: bsC130419 Date: 05/16/2001 java version "1.3.0" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3) Java HotSpot(TM) Client VM (build 1.3.0, mixed mode) [snoopy:~/test] jmwhit7% echo $CLASSPATH /home/jmwhit7/jini1_1/lib/jini-core.jar:/home/jmwhit7/jini1_1/lib/jini-ext.jar:/ home/jmwhit7/jini1_1/lib/outrigger.jar:/home/jmwhit7/jini1_1/lib/outrigger- dl.jar:. [snoopy:~] jmwhit7% cd test [snoopy:~/test] jmwhit7% ls MANIFEST Test.java [snoopy:~/test] jmwhit7% cat Test.java public class Test { public static void main (String [] argv) { System.out.println("$CLASSPATH=" + System.getProperty("java.class.path")); } } [snoopy:~/test] jmwhit7% cat MANIFEST Main-Class: Test [snoopy:~/test] jmwhit7% javac Test.java [snoopy:~/test] jmwhit7% java Test $CLASSPATH=/home/jmwhit7/jini1_1/lib/jini-core.jar:/home/jmwhit7/ jini1_1/lib/jini-ext.jar:/home/jmwhit7/jini1_1/lib/outrigger.jar:/home/ jmwhit7/jini1_1/lib/outrigger-dl.jar:. [snoopy:~/test] jmwhit7% java -cp $CLASSPATH Test $CLASSPATH=/home/jmwhit7/jini1_1/lib/jini-core.jar:/home/jmwhit7/ jini1_1/lib/jini-ext.jar:/home/jmwhit7/jini1_1/lib/outrigger.jar:/home/ jmwhit7/jini1_1/lib/outrigger-dl.jar:. [snoopy:~/test] jmwhit7% java -classpath $CLASSPATH Test $CLASSPATH=/home/jmwhit7/jini1_1/lib/jini-core.jar:/home/jmwhit7/ jini1_1/lib/jini-ext.jar:/home/jmwhit7/jini1_1/lib/outrigger.jar:/home/ jmwhit7/jini1_1/lib/outrigger-dl.jar:. [snoopy:~/test] jmwhit7% java -Djava.class.path=$CLASSPATH Test $CLASSPATH=/home/jmwhit7/jini1_1/lib/jini-core.jar:/home/jmwhit7/ jini1_1/lib/jini-ext.jar:/home/jmwhit7/jini1_1/lib/outrigger.jar:/home/ jmwhit7/jini1_1/lib/outrigger-dl.jar:. [snoopy:~/test] jmwhit7% jar cfm Test.jar MANIFEST Test.class [snoopy:~/test] jmwhit7% rm Test.class [snoopy:~/test] jmwhit7% ls MANIFEST Test.jar Test.java [snoopy:~/test] jmwhit7% java -jar Test.jar $CLASSPATH=Test.jar [snoopy:~/test] jmwhit7% java -jar -cp $CLASSPATH Test.jar $CLASSPATH=Test.jar [snoopy:~/test] jmwhit7% java -jar -classpath $CLASSPATH Test.jar $CLASSPATH=Test.jar [snoopy:~/test] jmwhit7% java -jar -Djava.class.path=$CLASSPATH Test.jar $CLASSPATH=Test.jar [snoopy:~/test] jmwhit7% (Review ID: 124477) ====================================================================== Name: rmT116609 Date: 01/29/2002 FULL PRODUCT VERSION : java version "1.3.1_02" Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.1_02-b02) Java HotSpot(TM) Client VM (build 1.3.1_02-b02, mixed mode) A DESCRIPTION OF THE PROBLEM : If I create an executable JAR file (by defining Main-Class in the manifest file), and then start the java run-time from the command line (java -cp c:\theProjectNeedsThese.jar -jar c:\theProject.jar), the application starts fine, but I get a NoClassDefFoundError because the class files in theProjectNeedsThese.jar are not recognized. The application only runs if I dump all of the class files contained in theProjectNeedsThese.jar into theProject.jar. How do I allow the executable JAR file to access classes contained in other JAR files? STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1. generate a simple executable JAR file which imports classes from a second JAR file 2. use the -jar option in the java runtime to start the executable JAR EXPECTED VERSUS ACTUAL BEHAVIOR : expected: the imported classes in the second JAR file will be accessible from the executable JAR. actual: classes in the second JAR are not found. ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.NoClassDefFoundError: This bug can be reproduced always. CUSTOMER WORKAROUND : Start the application using the .class file instead of the executable JAR file. (Review ID: 138942) ====================================================================== ###@###.### 10/28/04 01:06 GMT
|