Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6396787

java -classpath option does not work with -jar option.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0u1
    • tools
    • None
    • generic
    • generic

      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.

            darcy Joe Darcy
            sanjsaho Sanjeeb Sahoo
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: