United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-7067922 (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute
JDK-7067922 : (launcher) java -jar throws NPE if JAR file does not contain Main-Class attribute

Details
Type:
Bug
Submit Date:
2011-07-15
Status:
Closed
Updated Date:
2012-04-30
Project Name:
JDK
Resolved Date:
2012-04-21
Component:
tools
OS:
generic,windows_7
Sub-Component:
launcher
CPU:
x86,generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Duplicate:
Relates:

Sub Tasks

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
                                     
2011-07-18



Hardware and Software, Engineered to Work Together