United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6396787 java -classpath option does not work with -jar option.
JDK-6396787 : java -classpath option does not work with -jar option.

Details
Type:
Bug
Submit Date:
2006-03-10
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2006-03-10
Component:
tools
OS:
generic
Sub-Component:
launcher
CPU:
generic
Priority:
P3
Resolution:
Duplicate
Affected Versions:
5.0u1
Fixed Versions:

Related Reports
Duplicate:

Sub Tasks

Description
I have a jar file, a.jar, which contains A.class and its manifest has Main-Class attribute set to A. A.class depends on B.class. B.class is packaged inside b.jar.
When I run 'java -classpath a.jar:b.jar A', it is able to find B.class. 
When I run 'java -classpath b.jar -jar a.jar', it fails to find B.class as the following error shows:
Exception in thread "main" java.lang.NoClassDefFoundError: B
        at A.main(A.java:3)

Both a.jar, b.jar and A.java & B.java are included in attachment testcase.zip.

I am using JDK 1.5. When I tested with 1.6.0-beta2-b72, I got the same result.

                                    

Comments
EVALUATION

Using an executable jar is documented to ignore the other classpath components; closing as a duplicate of 4459663.
                                     
2006-03-10



Hardware and Software, Engineered to Work Together