JDK-6396787 : java -classpath option does not work with -jar option.
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 5.0u1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-03-10
  • Updated: 2011-02-16
  • Resolved: 2006-03-10
Related Reports
Duplicate :  
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