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

(launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute

    Details

    • Subcomponent:
    • Resolved In Build:
      b01
    • CPU:
      generic, x86
    • OS:
      generic, windows_7
    • Verification:
      Verified

      Backports

        Description

        If you create a jar file WITHOUT a “Main-Class” manifest field, and you try to run it by java –jar xxx.jar using Java 7 b147, you get this:

        Exception in thread "main" java.lang.NullPointerException
                at sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:399)
                at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:463)

        However if you do the same thing in Java 6, you get this:
                Failed to load Main-Class manifest attribute from
                stringbenchmarkmissingmainclass.jar

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  ksrini Kumar Srinivasan
                  Reporter:
                  ryeung Roger Yeung (Inactive)
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Imported:
                    Indexed: