Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 6694671
Votes 0
Synopsis "check your installation" mesage for invoking a class without main()
Category java:tools
Reported Against
Release Fixed
State 11-Closed, duplicate of 6742159, bug
Priority: 3-Medium
Related Bugs 6684582
Submit Date 28-APR-2008
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.
Posted Date : 2008-04-28 07:18:42.0
Work Around
N/A
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.
Posted Date : 2008-04-28 14:57:35.0

The error message has been diluted and made easier to swallow with the fix for
CR: 6742159
Posted Date : 2008-09-24 22:11:01.0
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang