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)").
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; 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 开发者_JAVA百科guide.
There are older versions of Java installed on the server, but I can't do anything about that. Is there anything else I can do about this error?
Use sudo update-alternatives --config java
and set the version you may want to use if you are using a Debian-derived distro (such as Ubuntu).
Aside from setting JAVA_HOME
appropriately (which you've done), ensure that you're executing the right version of the java
executable. e.g., on Debian or Ubuntu, execute /usr/lib/jvm/java-6-openjdk/jre/bin/java
directly, if /usr/bin/java
points to the wrong version.
You can use the -version
option to verify the version of the launcher you're using. Try java -version
and /usr/lib/jvm/java-6-openjdk/jre/bin/java -version
and see if the output is any different.
Making sure that JAVA_HOME
is set to a particular Java installation is not necessarily enough.
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.
It is likely that your java veriosn is still 1.5 even if you have set JAVA_HOME to 1.6
Type java -version
on the console and see what version it prints.
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.
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. Set Compiler Compliance level to 1.7.Once you press 'Apply', it would ask you to rebuild the program. 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. Choose either to configure installed JREs or set your environment variable. Once you are done, you are good to go!
精彩评论