[英]Exception in thread “main” java.lang.UnsupportedClassVersionError: danbikel/parser/Trainer (Unsupported major.minor version 50.0)
I'm trying to run a parser built in Java, but every time I try to use the class, I get the above error ("Exception in thread "main" java.lang.UnsupportedClassVersionError: danbikel/parser/Trainer (Unsupported major.minor version 50.0)"). 我正在尝试运行一个用Java构建的解析器,但每次我尝试使用该类时,我都会收到上述错误(“线程中的异常”主“java.lang.UnsupportedClassVersionError:danbikel / parser / Trainer(不支持的主要版本)。次要版本50.0)“)。
From what I've read, this may be a problem with a mismatch between the versions of Java used to compile and run the code; 根据我的阅读,这可能是用于编译和运行代码的Java版本之间不匹配的问题; but I've made sure that my JAVA_HOME environment is set to version 1.6, which is the version recommended by the parser's installation guide.
但我确保我的JAVA_HOME环境设置为1.6版本,这是解析器安装指南推荐的版本。
There are older versions of Java installed on the server, but I can't do anything about that. 服务器上安装了旧版本的Java,但我对此无能为力。 Is there anything else I can do about this error?
我还能做些什么来解决这个错误吗?
如果您使用的是Debian派生的发行版(例如Ubuntu),请使用sudo update-alternatives --config java
并设置您可能要使用的版本。
Aside from setting JAVA_HOME
appropriately (which you've done), ensure that you're executing the right version of the java
executable. 除了适当地设置
JAVA_HOME
(你已经完成),确保你正在执行正确版本的java
可执行文件。 eg, on Debian or Ubuntu, execute /usr/lib/jvm/java-6-openjdk/jre/bin/java
directly, if /usr/bin/java
points to the wrong version. 例如,在Debian或Ubuntu上,如果
/usr/bin/java
指向错误的版本,则直接执行/usr/lib/jvm/java-6-openjdk/jre/bin/java
。
You can use the -version
option to verify the version of the launcher you're using. 您可以使用
-version
选项验证您正在使用的启动器的版本。 Try java -version
and /usr/lib/jvm/java-6-openjdk/jre/bin/java -version
and see if the output is any different. 尝试使用
java -version
和/usr/lib/jvm/java-6-openjdk/jre/bin/java -version
查看输出是否有任何不同。
Making sure that JAVA_HOME
is set to a particular Java installation is not necessarily enough. 确保将
JAVA_HOME
设置为特定的Java安装并不一定足够。
If you have more information on your server and the configuration environment used it would be helpful. 如果您有关于服务器和配置环境的更多信息,那将会很有帮助。
I would make sure that your PATH
environment includes ${JAVA_HOME}/bin:${PATH}
if you want to make absolutely sure you are using the correct version. 如果您想确保使用正确的版本,我会确保您的
PATH
环境包含${JAVA_HOME}/bin:${PATH}
。
It is likely that your java veriosn is still 1.5 even if you have set JAVA_HOME to 1.6 即使您已将JAVA_HOME设置为1.6,您的java veriosn仍可能仍为1.5
Type java -version
on the console and see what version it prints. 在控制台上键入
java -version
并查看它打印的版本。
I also had this problem and I resolved it after I found that I had set a custom JAVA_HOME value in my .bash_profile. 我也遇到了这个问题,在发现我在.bash_profile中设置了自定义JAVA_HOME值后,我解决了这个问题。
I commented this out, loaded a new console and now my project builds. 我评论了这个,加载了一个新的控制台,现在我的项目构建了。
For me this worked: 1) install JRE 7 2) Install JDK 3) Go to Project Properties>Java Compiler. 对我来说,这工作:1)安装JRE 7 2)安装JDK 3)转到项目属性> Java编译器。 Set Compiler Compliance level to 1.7.Once you press 'Apply', it would ask you to rebuild the program.
将编译器合规性级别设置为1.7。一旦按“应用”,它将要求您重建程序。 For most people that should do it.
对于大多数应该这样做的人。 For the rest, see a warning section(marked with an yellow '!' mark) appears at the bottom of the Properties window, where it asks to search for the compatible JRE.
对于其余部分,请在“属性”窗口的底部显示警告部分(标有黄色“!”标记),要求搜索兼容的JRE。 Choose either to configure installed JREs or set your environment variable.
选择配置已安装的JRE或设置环境变量。 Once you are done, you are good to go!
完成后,你很高兴!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.