JDK-7067922 : (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
  • Type: Bug
  • Component: tools
  • Sub-Component: launcher
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,windows_7
  • CPU: generic,x86
  • Submitted: 2011-07-15
  • Updated: 2012-04-30
  • Resolved: 2012-04-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7 JDK 8
7u2Fixed 8 b01Fixed
Related Reports
Duplicate :  
Relates :  
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

Comments
EVALUATION Missing check for Null value in LauncherHelper.java
18-07-2011