开发者

help - testng doesnt work on the mac with eclipse: Bad version number in .class file

开发者 https://www.devze.com 2023-01-18 12:53 出处:网络
To get latest Helios eclipse + subclipse + m2eclipse and mvn to work on the mac, I had to make the \"default\" jdk 1.6 thusly:

To get latest Helios eclipse + subclipse + m2eclipse and mvn to work on the mac, I had to make the "default" jdk 1.6 thusly:

cd /System/Library/Frameworks/JavaVM.framework/Versions
ln -s 1.6 CurrentJDK

AN开发者_StackOverflow中文版D I had to enable 1.6 using the applications/utilities/java preferences app.

Now eclipse, and mvn work, with 1.6 set as the target everywhere.

But the testNG eclipse plugin does not work. It gives this error when you try and run any tests:

Plug-in org.testng.eclipse was unable to load class  org.testng.eclipse.launch.TestNGSuiteLaunchShortcut.

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.defineClass(DefaultClassLoader.java:188)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.defineClass(ClasspathManager.java:580) 
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findClassImpl(ClasspathManager.java:550)
at org.eclipse.osgi.baseadaptor.loader.ClasspathManager.findLocalClassImpl(ClasspathManager.java:481)
at ....

If I try any other combination of java versions, eclipse wont start. I cant find any "eclipse.ini" or similar where you can hard wire the java version, which I had to do on XP to use 1.6.

In the Java Preferences app (which takes minutes to load), I have to have the following ticked:

Java SE 6    64-bit
J2SE 5.0     32-bit
J2SE 5.0     64-bit.

If I untick any of the J2SE 5.0 ones, eclipse wont start, even though CurrentJava is set to 1.6.

If I do

java -version 

on the command line, I get: java version "1.6.0_20"

Mind you, it gave that even when "CurrentJDK" was pointing to 1.5.

I suspect that the problem is that eclipse is running 1.5 VM, but there seems to be no way to change that or test if it is the case. Help->install new sw->already installed->Configuration shows this:

eclipse.vm=/System/Library/Frameworks/JavaVM.framework
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5

I found that you could indeed edit the eclipse.ini if you hold down the control key and right click on eclipse.app. I hate the mac. I added this:

-vm
/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK

But now when I try and launch eclipse, I get:

Version 1.5.0_24 of the JVM is not suitable for this product.
Version 1.6 or greater is required.

What more can man do to try and get a mac to use 1.6?

Has anyone got any ideas I can try?

I also tried putting this:

-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java

At various points in the ini file, e.g:

-startup
../../../plugins/org.eclipse.equinox.launcher_1.1.0.v20100507.jar
--launcher.library
../../../plugins/org.eclipse.equinox.launcher.cocoa.macosx_1.1.0.v20100503
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m
-Xdock:icon=../Resources/Eclipse.icns
-XstartOnFirstThread
-Dorg.eclipse.swt.internal.carbon.smallFonts

But when I try and then startup eclipse, I get:

Failed to create the Java Virtual Machine.


What version of the TestNG plug-in are you using? Please make sure you update to the latest (5.14.1.6 as of this writing) and report back.

The plug-in is not just 1.6 compatible (obviously), it's also 1.5 compatible and I've tested it with both JDK's and also both Eclipse 3.5 and 3.6.

If the problem persists, can you try to run the plug-in on a fresh workspace?

Thanks.

--
Cédric

0

精彩评论

暂无评论...
验证码 换一张
取 消