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.
$ $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.
- duplicates
-
JDK-6742159 (launcher) improve the java launching mechanism
-
- Closed
-
- relates to
-
JDK-8167063 spurious message "A JNI error has occurred" if start-class cannot be initialized
-
- Closed
-
-
JDK-6684582 Launcher needs improved error reporting
-
- Closed
-