Bug 288991 - Run simple java on eclipse, UnsupportedClassVersionError
Run simple java on eclipse, UnsupportedClassVersionError
Product: Fedora
Classification: Fedora
Component: eclipse (Show other bugs)
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Andrew Overholt
Fedora Extras Quality Assurance
: 310571 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2007-09-13 06:18 EDT by sangu
Modified: 2007-11-30 17:12 EST (History)
5 users (show)

See Also:
Fixed In Version: 3.3.0-22.fc8
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-10-03 14:53:56 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description sangu 2007-09-13 06:18:03 EDT
Description of problem:

class HelloWorld {

	 * @param args
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		System.out.println("Hello world!");


== console on eclipse ==
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld :
Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:638)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:143)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:281)
	at java.net.URLClassLoader.access$000(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:216)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:209)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:324)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:269)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:337)

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. $yum install eclipse
2. launch eclipse
3. Create HelloWorld Project in eclipse tutorial
4. Run 

Actual results:

Expected results:

Additional info:

$javac ~/workspace/HelloWorld/src/HelloWorld.java
$java ~/workspace/HelloWorld/src/HelloWorld
Hello world!

$ rpm -qa | grep ^eclipse

$ rpm -q java-1.7.0-icedtea
Comment 1 sangu 2007-09-13 07:31:33 EDT
After Compiler compliance level is set to 1.4.,  run works well.

Initial Compiler compliance level value is 6. <-- this is bug?

Click Restore Defaults,  Compiler compliance level changes to 1.4.
Comment 2 Andrew Overholt 2007-09-13 13:35:15 EDT
I don't understand.  Is ecj generating something that IcedTea can't run?  Tom,
do you have any idea what's up here?
Comment 3 Thomas Fitzsimmons 2007-09-13 15:41:02 EDT
51 is the 1.7 major version so the code is being built by IcedTea.  sangu, what
JDK is Eclipse configured to run programs with?
Comment 4 sangu 2007-09-13 19:37:34 EDT
$rm -rf ~/.eclipse ~/workspace/
1. Launch eclipse
( Compiler compliance level 6)
2. Make helloworld project in tutorials
(Create Hello World application)
3. Run

1. Window menu  -> Preferences - Java - Compiler -> Compiler compliance level
6.0 -> 1.4
2. Run 
Works well.

* Compiler compliance level 6 (Initial value)
- Run -> UnsupportedClassVersionError 

*  Compiler compliance level 1.4  (Click Restore Defaults)
- Run -> Works well.
Comment 5 Sylvain Pasche 2007-09-15 09:02:30 EDT
Looks like there are some troubles with IcedTea: it can't run .class files it

javac -target 1.7 Hello.java
java Hello

Exception in thread "main" java.lang.UnsupportedClassVersionError: Hello :
Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
Comment 6 Andrew Overholt 2007-09-15 09:26:42 EDT
Updating component.
Comment 7 Thomas Fitzsimmons 2007-09-17 13:27:01 EDT
From openjdk/hotspot/src/share/vm/classfile/classFileParser.cpp:


OpenJDK represents the Java 1.7 development cycle.  It's unknown whether a class
file format version bump will be required once Java 1.7 is finalized.  In the
mean time, people shouldn't be building with -target 1.7 (except maybe javac
developers), and I expect JAVA_MAX_SUPPORTED_VERSION 50 is a reminder of this.

The correct fix here is to make Eclipse build with -target 1.6 rather than 1.7.
Comment 8 Andrew Overholt 2007-09-18 13:47:47 EDT
This is going to be difficult.
Comment 9 Andrew Overholt 2007-09-26 15:41:42 EDT
It turns out it's not difficult at all :)  I'm uncomfortable making this change
at such a low level, but I guess someone running on OpenJDK can generate
1.7-level bytecode if they so choose by changing their project properties.

I've included a patch and a build should show up in rawhide tomorrow (2007-09-27).
Comment 10 Andrew Overholt 2007-09-28 08:32:14 EDT
Can someone please verify that this is fixed in 3.3.0-22.fc8?
Comment 11 Andrew Overholt 2007-09-28 08:33:51 EDT
*** Bug 310571 has been marked as a duplicate of this bug. ***
Comment 12 Thomas Fitzsimmons 2007-10-03 13:24:53 EDT
Confirmed fixed in 3.3.0-22.fc8.
Comment 13 Andrew Overholt 2007-10-03 14:53:56 EDT
Thanks, closing.

Note You need to log in before you can comment on or make changes to this bug.