简体   繁体   English

help-testng在带eclipse的Mac上不起作用:.class文件中的版本号错误

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

To get latest Helios eclipse + subclipse + m2eclipse and mvn to work on the mac, I had to make the "default" jdk 1.6 thusly: 为了在Mac上运行最新的Helios eclipse + subclipse + m2eclipse和mvn,我必须这样设置“默认” jdk 1.6:

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

AND I had to enable 1.6 using the applications/utilities/java preferences app. 并且我必须使用apps / utilities / java preferences应用程序启用1.6。

Now eclipse, and mvn work, with 1.6 set as the target everywhere. 现在,eclipse和mvn都可以正常工作,并且将1.6设置为目标。

But the testNG eclipse plugin does not work. 但是testNG eclipse插件不起作用。 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. 如果我尝试其他任何Java版本组合,则eclipse不会启动。 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. 我找不到任何“ eclipse.ini”或类似名称可以在其中硬连接Java版本,而我必须在XP上才能使用1.6。

In the Java Preferences app (which takes minutes to load), I have to have the following ticked: 在Java Preferences应用程序(加载过程需要几分钟)中,我必须勾选以下内容:

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. 如果我取消选中任何J2SE 5.0,即使CurrentJava设置为1.6,eclipse也不会启动。

If I do 如果我做

java -version 

on the command line, I get: java version "1.6.0_20" 在命令行上,我得到:Java版本“ 1.6.0_20”

Mind you, it gave that even when "CurrentJDK" was pointing to 1.5. 提醒您,即使“ CurrentJDK”指向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. 我怀疑问题是eclipse运行的是1.5 VM,但是似乎没有办法更改它或测试情况是否如此。 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. 我发现如果按住Control键并右键单击eclipse.app,则确实可以编辑eclipse.ini。 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: 但是现在当我尝试启动eclipse时,我得到:

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? 人们还能做些什么来尝试使Mac使用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, eg: 在ini文件的各个位置,例如:

-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: 但是当我尝试然后启动eclipse时,我得到:

Failed to create the Java Virtual Machine.

What version of the TestNG plug-in are you using? 您正在使用哪个版本的TestNG插件? Please make sure you update to the latest (5.14.1.6 as of this writing) and report back. 请确保您更新到最新版本(在撰写本文时为5.14.1.6)并进行报告。

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. 该插件不仅与1.6兼容(显然),而且与1.5兼容,我已经在JDK和Eclipse 3.5和3.6上进行了测试。

If the problem persists, can you try to run the plug-in on a fresh workspace? 如果问题仍然存在,您可以尝试在新的工作空间上运行插件吗?

Thanks. 谢谢。

-- -
Cédric 塞德里克

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM