Elasticsearch: Unsupported major.minor version 52.0

Created on 7 Apr 2016  路  18Comments  路  Source: elastic/elasticsearch

I tried elasticsearch 5.0-alpha this morning (on Ubuntu 14.04) , both the deb package and the tar file give me a " Unsupported major.minor version 52.0" error.

I have the latest openjdk installed.

See Error , os and java below.

root@sin-cpt-sl-es-development:~/elasticsearch-5.0.0-alpha1# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.4 LTS
Release: 14.04
Codename: trusty
root@sin-cpt-sl-es-development:~/elasticsearch-5.0.0-alpha1# ./bin/elasticsearch
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 java.lang.ClassLoader.defineClass(ClassLoader.java:803)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
root@sin-cpt-sl-es-development:~/elasticsearch-5.0.0-alpha1# java -version
java version "1.7.0_95"
OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-0ubuntu0.14.04.2)
OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
root@sin-cpt-sl-es-development:~/elasticsearch-5.0.0-alpha1#

Most helpful comment

Just install java 8.

All 18 comments

Thanks for trying 5.0 aplha1. ES 5.0 will require Java8 as a minimum. See "https://www.elastic.co/guide/en/elasticsearch/reference/master/_installation.html#_installation"

I wish the error message was clearer, but as it comes from the JVM I don't think we have control over it.

Ah , thanx - I saw a similar issue on a previous version , so I suspected java. But since I did update to the latest (available) version I thought maybe it was something else.

Turns out ubuntu 14.04 just doesnt have openjdk 8 in the repos - so installed from ppa and now everything seems to be working.

@bleskes can we add Java8 requirement to this doc https://www.elastic.co/guide/en/elasticsearch/reference/master/rpm.html
to be consistent to other v5 docs such as logstash and help this these issues?

@calbatron I've opened #20005

Just install java 8.

C:\elasticsearch-5.2.0\bin>elasticsearch.bat
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 java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

C:\elasticsearch-5.2.0\bin>java -version
java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

C:\elasticsearch-5.2.0\bin>

@bleskes Shouldn't the upgrade checker plugin check this?

@LaszloHont I think it should but it doesn't now. I opened https://github.com/elastic/elasticsearch-migration/issues/102

v2.0.4 of the migration plugin checks the JVM version now

In Ubuntu use in terminal commands:
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
sudo apt install oracle-java9-installer

When I set JAVA_HOME to jdk 1.8 in command prompt it worked without any issue. Thanks for your posting.

Elasticsearch will not pick java from path environment variable in windows. It check for JAVA_HOME set up in Environment Variable , Please make sure to put correct java for example using 5.2.2 version setup JAVA_HOME as java 8 JDK/JRE.

I am following the documentation of ES (https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/java-docs-index.html). I am getting the following error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/common/transport/TransportAddress : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getMethod0(Class.java:2774)
at java.lang.Class.getMethod(Class.java:1663)
at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)

Here is a part of screenshot of my config of eclipse:
java.awt.graphicsenv=sun.awt.CGraphicsEnvironment
java.awt.printerjob=sun.lwawt.macosx.CPrinterJob
java.class.path=/Users/JohnDoe/eclipse/java-neon/Eclipse.app/Contents/MacOS//../Eclipse/plugins/org.eclipse.equinox.launcher_1.3.201.v20161025-1711.jar
java.class.version=52.0
java.endorsed.dirs=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/endorsed
java.ext.dirs=/Users/JohnDoe/Library/Java/Extensions:/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre/lib/ext:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java
java.home=/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/jre

I have spent a lot of time trying to get the version of JAVA used. From the above config file, it seems it is Java 8. How do I resolve this issue?

@shahkaushal94 feel free to ask on discuss.elastic.co where we can give better support.
Here, it's clear that you still have a java 1.7 version somewhere.

Check your JAVA_HOME and what gives java -version.

$java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

Sure, I'll ask questions on discuss.elastic.co. Sorry.
But why is my java version showing 1.8 then?

You can see that something is inconsistent here:

java version "1.8.0_131"

and

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

Thanks! I did a complete reinstall of java and it worked. I have more questions! Will post on discuss.elastic.co

The debian packages you distribute on your webpage really should include a dependency for matching java packages. They all install flawlessly and then stuff does not work and the error message is not totally self explanatory.

Was this page helpful?
0 / 5 - 0 ratings