Tuesday 12 February 2013

Java troubleshooting: Unsupported major.minor version ##.#

While running a Main-class I got "Unsupported major.minor version 52.0". The problem that I compiled (javac) with JDK 1.8 but I run (java) the code with the older JRE 1.7.
$ javac -version
javac 1.8.0-ea
$ java -version
java version "1.7.0_13"
Java(TM) SE Runtime Environment (build 1.7.0_13-b20)
Java HotSpot(TM) 64-Bit Server VM (build 23.7-b01, mixed mode)
The solution is to use the same JRE and JDK version:
$ sudo update-alternatives --config javac
[sudo] password for micharg: 
There are 3 choices for the alternative javac (providing /usr/bin/javac).

  Selection    Path                                  Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-8-oracle/bin/javac   15        auto mode
  1            /usr/lib/jvm/java-6-oracle/bin/javac   12        manual mode
  2            /usr/lib/jvm/java-7-oracle/bin/javac   13        manual mode
  3            /usr/lib/jvm/java-8-oracle/bin/javac   15        manual mode

Press enter to keep the current choice[*], or type selection number: 2

No comments:

Post a Comment