简体   繁体   中英

Elasticsearch: Unsupported major.minor version 52.0

I know that the "Unsupported major.minor version 52.0" Error points to the fact that the java code was compiled with Java 8 and it was attempted to execute it with an earlier version.

I know that it is therefore suggested to have JAVA_HOME and PATH point to the correct version of Java.

From all that I can tell I have my system already pointing to the correct version:

me@computer ~ $ java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)
me@computer ~ $ which java
/home/me/bin/jdk1.8.0_102_64bit/bin/java
me@computer ~ $ echo $JAVA_HOME
/home/me/bin/jdk1.8.0_102_64bit

However, I still get the below error when trying to execute elasticsearch (installed via apt-get):

me@computer ~ $ sudo -i service elasticsearch start
 * Starting Elasticsearch Server
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
...
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

Edit:

The PATH variable (in constrast to other variables like JAVA_HOME) is reset with sudo on ubuntu-based linuxes, one suggested solution is to set the variable again using sudo env :

me@computer ~ $ sudo echo $JAVA_HOME
/home/me/bin/jdk1.8.0_102_64bit
me@computer ~ $ sudo java -version
java version "1.7.0_121"
OpenJDK Runtime Environment (IcedTea 2.6.8) (7u121-2.6.8-1ubuntu0.14.04.1)
OpenJDK 64-Bit Server VM (build 24.121-b00, mixed mode)
me@computer ~ $ sudo env PATH=$PATH java -version
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)

However, this does not work for my actual problem (starting Elasticsearch):

me@computer ~ $ sudo env PATH=$PATH service elasticsearch start
 * Starting Elasticsearch Server
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 52.0
    at java.lang.ClassLoader.defineClass1(Native Method)
...

+1

having same issue on Debian Jessie

Distributor ID: Debian Description: Debian GNU/Linux 8.6 (jessie) Release: 8.6 Codename: jessie

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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