United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6694671 "check your installation" mesage for invoking a class without main()
JDK-6694671 : "check your installation" mesage for invoking a class without main()

Details
Type:
Bug
Submit Date:
2008-04-28
Status:
Closed
Updated Date:
2011-02-16
Project Name:
JDK
Resolved Date:
2008-09-24
Component:
tools
OS:
solaris_10
Sub-Component:
launcher
CPU:
x86
Priority:
P3
Resolution:
Duplicate
Affected Versions:
7
Fixed Versions:

Related Reports
Duplicate:
Relates:

Sub Tasks

Description
FULL PRODUCT VERSION :
$ $Deployed/JDK-7/bin/java -version
java version "1.7.0-ea"
Java(TM) SE Runtime Environment (build 1.7.0-ea-b25)
Java HotSpot(TM) Client VM (build 12.0-b01, mixed mode, sharing)


ADDITIONAL OS VERSION INFORMATION :
$ uname -a
SunOS Peapod 5.11 snv_79 i86pc i386 i86pc

EXTRA RELEVANT SYSTEM CONFIGURATION :
-- generic --

A DESCRIPTION OF THE PROBLEM :
I accidentally tried to run a class other than the one that has the main(String[]) method for my application.  I received two error messages:

    $ $Deployed/JDK-7/bin/java TestCell
    Exception in thread "main" java.lang.NoSuchMethodError: main
    Error: A JNI error has occurred, please check your installation and try again

The first message says that the JVM couldn't find a method called main, which describes the mistake I made perfectly.  Maybe it could be worded better for newbies, but it's not wrong.

The second message is way beyond newbies (who are the ones most likely to make this mistake!).  If I were a newbie I might worry that I had installed Java incorrectly, or something.

The second message is new in JDK-7: it does *not* appear in JDK-1.6.0_03-b05.

This seems like a common mistake and a more gentle and informative error message would be a better user experience.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
$ cat Foo.java
public class Foo {}
$ $Deployed/JDK-7/bin/javac Foo.java
$ $Deployed/JDK-7/bin/java Foo
Exception in thread "main" java.lang.NoSuchMethodError: main
Error: A JNI error has occurred, please check your installation and try again


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
    Exception in thread "main" java.lang.NoSuchMethodError: main

(or something more explanatory for this special case of that error)
ACTUAL -
    Exception in thread "main" java.lang.NoSuchMethodError: main
    Error: A JNI error has occurred, please check your installation and try again


ERROR MESSAGES/STACK TRACES THAT OCCUR :
-- See above --

REPRODUCIBILITY :
This bug can be reproduced always.

---------- BEGIN SOURCE ----------
public class Foo {}

---------- END SOURCE ----------

CUSTOMER SUBMITTED WORKAROUND :
Use JDK-1.6.0_03-b05:

    $ /usr/bin/java -showversion Foo
    java version "1.6.0_03"
    Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
    Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)
    
    Exception in thread "main" java.lang.NoSuchMethodError: main

Except we'd like everyone to move to JDK-7, so making the user experience harsher is a step backwards.

Release Regression From : 7
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

Release Regression From : 6u10
The above release value was the last known release where this 
bug was not reproducible. Since then there has been a regression.

                                    

Comments
EVALUATION

There has been an additional fix in this area to pinpoint the main class
by the way of CR: 6684582, however the second line is being printed. One
must understand that we do get a generic JNI error and this could mean
several things a user error as in the case noted, or it could mean the
installation went awry for first time installs. There is no clear way
to discern this, that is why the second message is printed, perhaps the
second message can be output if the user wanted to more info. by the
way of debug flag.
                                     
2008-04-28
EVALUATION

The error message has been diluted and made easier to swallow with the fix for
CR: 6742159
                                     
2008-09-24



Hardware and Software, Engineered to Work Together