tags:

views:

2234

answers:

7

Hi,

I am trying to run Eclipse 3.4.1 on MacOS 10.5.6? I think I am using java 1.5 when I run eclipse:

$ which java /usr/bin/java $ java -version java version "1.5.0_16" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)

And then I click eclipse icon.

In the Preferences->Java->Installed JREs, I did click 'JVM 1.6.0', since I needs to use 1.6 for my project.

But in the .log file, I am getting these errors, why there is class file bad version number? And how can I fix it?




!SESSION 2009-01-29 10:07:29.618 -----------------------------------------------
eclipse.buildId=M20080911-1700
java.version=1.5.0_16
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86, WS=carbon, NL=en_US
Framework arguments:  -keyring /Users/samuel/.eclipse_keyring -showlocation
Command-line arguments:  -os macosx -ws carbon -arch x86 -keyring /Users/samuel/
.eclipse_keyring -consoleLog -showlocation

!ENTRY com.android.ide.eclipse.adt 4 0 2009-01-29 10:07:42.947
!MESSAGE Failed to start com.android.ide.eclipse.editors
!STACK 0
org.osgi.framework.BundleException: Exception in com.android.ide.eclipse.editors
.EditorsPlugin.start() of bundle com.android.ide.eclipse.editors.
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActiv
ator(BundleContextImpl.java:1028)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:984)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:346)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:265)
        at com.android.ide.eclipse.adt.AdtPlugin$11.run(Unknown Source)
Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class 
file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:520)
        at com.android.ide.eclipse.editors.resources.manager.ProjectClassLoader.
findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at com.android.ide.eclipse.editors.resources.manager.CompiledResourcesMo
nitor.loadAndParseRClass(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.CompiledResourcesMo
nitor.projectOpenedWithWorkspace(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.ResourceMonitor.add
ProjectListener(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.CompiledResourcesMo
nitor.setupMonitor(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.ResourceManager.set
up(Unknown Source)
        at com.android.ide.eclipse.editors.EditorsPlugin.start(Unknown Source)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(Bund
leContextImpl.java:1009)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActiv
ator(BundleContextImpl.java:1003)
        ... 4 more
Root exception:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:675)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:520)
        at com.android.ide.eclipse.editors.resources.manager.ProjectClassLoader.
findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:316)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at com.android.ide.eclipse.editors.resources.manager.CompiledResourcesMo
nitor.loadAndParseRClass(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.CompiledResourcesMo
nitor.projectOpenedWithWorkspace(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.ResourceMonitor.add
ProjectListener(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.CompiledResourcesMo
nitor.setupMonitor(Unknown Source)
        at com.android.ide.eclipse.editors.resources.manager.ResourceManager.set
up(Unknown Source)
        at com.android.ide.eclipse.editors.EditorsPlugin.start(Unknown Source)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(Bund
leContextImpl.java:1009)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActiv
ator(BundleContextImpl.java:1003)
        at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(Bund
leContextImpl.java:984)
        at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(Bundl
eHost.java:346)
        at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(Abstrac
tBundle.java:265)
        at com.android.ide.eclipse.adt.AdtPlugin$11.run(Unknown Source)


+1  A: 

Take a look at this line:

java.lang.UnsupportedClassVersionError: Bad version number in .class file

That error means that you're attempting to execute bytecode in a JRE that is older than the JDK you used to compile. In your case, the version 5 JRE doesn't recognise the file magic added by the v6 JDK and quits before it hits bytecode it can't understand.

The solution to this is to either specify a target version for the compiler, or upgrade your JRE.

David Grant
+2  A: 

Eclipse on Mac OS X on Intels only works with JDK 5 (it's horrible). I always have to create two versions of my plugins.

However, it seems that the Android editor plugin that you're using was compiled against 1.6, so I'm not sure that there's a solution...

Uri
Thanks. But from the android document, it said 'JDK 5 or JDK 6' will work.http://code.google.com/android/intro/installing.htmlSo I am confused.
yinglcs
not true! been using JDK 1.6 for a year now on my MacBook Pro.
Pat
+1  A: 

You will need to install java 6 on to your Mac if you want to 1.6 in your project. You should be able to get java 6 here:

http://developer.apple.com/java/download/

Ruggs
Thanks. I have java 6 and java 5 on my Mac. But I think eclipse 3.4 needs java 5 to work.
yinglcs
A: 

You can try the latest Galileo (Eclipse 3.5) milestone. It is not very stable, but it will run on Apple's JDK 1.6. Get it here (3.5M4 is the latest). Make sure you get the cocoa 64 bit version.

Start it with -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java

Again, an early beta with all implications.

zvikico
In the notes for 3.5M4 Cocoa it says "Eclipse does not currently run on (64-bit) Java 1.6."
Fabian Steeg
A: 

I tried you suggestion. But I get a different error:

I did try running the eclipse 3.5M4 with this "./eclipse -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home"

SESSION 2009-01-29 15:39:02.956 -----------------------------------------------
eclipse.buildId=I20081211-1908
java.version=1.6.0_07
java.vendor=Apple Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_US
Command-line arguments:  -os macosx -ws cocoa -arch x86_64

!ENTRY org.eclipse.core.net 1 0 2009-01-29 15:39:11.363
!MESSAGE System property http.nonProxyHosts has been set to local|*.local|169.254/16|*.169.254/16 by an external
 source. This value will be overwritten using the values from the preferences

!ENTRY org.eclipse.core.filesystem 1 1 2009-01-29 15:42:54.529
!MESSAGE Could not load library: liblocalfile_1_0_0.jnilib.  This library provides platform-specific optimizatio
ns for certain file system operations.  This library is not present on all platforms, so this may not be an erro
r.  The resources plug-in will safely fall back to using java.io.File functionality.
!STACK 0
java.lang.UnsatisfiedLinkError: no localfile_1_0_0 in java.library.path
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1753)
        at java.lang.Runtime.loadLibrary0(Runtime.java:823)
        at java.lang.System.loadLibrary(System.java:1030)
        at org.eclipse.core.internal.filesystem.local.LocalFileNatives.(LocalFileNatives.java:32)
        at org.eclipse.core.internal.filesystem.local.LocalFile.fetchInfo(LocalFile.java:142)
        at org.eclipse.core.filesystem.provider.FileStore.fetchInfo(FileStore.java:277)
        at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:40)
        at org.eclipse.core.internal.resources.Project.create(Project.java:252)
        at org.eclipse.core.internal.resources.Project.create(Project.java:234)
        at com.android.ide.eclipse.adt.project.internal.NewProjectWizard.createProjectAsync(Unknown Source)
        at com.android.ide.eclipse.adt.project.internal.NewProjectWizard.access$0(Unknown Source)
        at com.android.ide.eclipse.adt.project.internal.NewProjectWizard$1.execute(Unknown Source)
        at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
        at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1800)
        at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
        at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

yinglcs
+1  A: 

I was able to get Eclipse 3.5M5 to run with JDK 1.6.0 as its base VM with a slightly modified path from above:

./eclipse -vm /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0

Better, I was able to put it in the eclipse.ini file in /Applications/eclipse3.5/Eclipse.app/Contents/MacOS, so long as it went above the '-vmargs'. For example:

-startup
../../../plugins/org.eclipse.equinox.launcher_1.0.200.v20090128-1500.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx.x86_64_1.0.0.v20081125-1800
-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0
-showsplash
org.eclipse.platform
-vmargs
...
jbrugge
A: 

I set

export JAVA_VERSION=1.6
Pat