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

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

XMLWordPrintable

    • b01
    • generic, x86
    • generic, windows_7
    • Verified

        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

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

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: