Exception in thread “main” java.lang.UnsupportedClassVersionError: org/elasticsearch/plugins/PluginCli : Unsupported major.minor version 52.0

The aws ec2-instance has older version has Java 1.7. The latest version of the elastic-search requires Java 1.8. If you try to install the plugin like x-pack now, you will get this error:

[ec2-user@ip-10-0-20-199 bin]$ sudo ./elasticsearch-plugin install x-pack[ec2-user@ip-10-0-20-199 bin]$ sudo ./elasticsearch-plugin install x-packException in thread “main” java.lang.UnsupportedClassVersionError: org/elasticsearch/plugins/PluginCli : 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:442) at java.net.URLClassLoader.access$100(URLClassLoader.java:64) at java.net.URLClassLoader$1.run(URLClassLoader.java:354) at java.net.URLClassLoader$1.run(URLClassLoader.java:348) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:347) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:312) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)[ec2-user@ip-10-0-20-199 bin]$ packet_write_wait: Connection to 35.154.108.46 port 22: Broken pipe

The fix is simple, update the Java version to 1.8.

This how we do it on aws ec2 instance:

[ec2-user@ip-10-0-20-199 ~]$ sudo yum install java-1.8.0
[ec2-user@ip-10-0-20-199 ~]$ sudo /usr/sbin/alternatives –config java
[ec2-user@ip-10-0-20-199 ~]$ sudo /usr/sbin/alternatives –config java

There are 2 programs which provide ‘java’.

Selection Command
———————————————–
*+ 1 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
2 /usr/lib/jvm/jre-1.8.0-openjdk.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 2

 

 

Advertisements

ERROR: Failed to build gem native extension

I was trying to install ruby gem for nats, and I got this error:

[ec2-user@ip-xx-xx-xx-xx nats]$ sudo gem install nats
Building native extensions. This could take a while…
ERROR: Error installing nats:
ERROR: Failed to build gem native extension.

current directory: /usr/local/share/ruby/gems/2.0/gems/eventmachine-1.2.3/ext
/usr/bin/ruby2.0 -r ./siteconf20170630-22515-1601fpy.rb extconf.rb
mkmf.rb can’t find header files for ruby at /usr/share/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /usr/local/share/ruby/gems/2.0/gems/eventmachine-1.2.3 for inspection.
Results logged to /usr/local/lib64/ruby/gems/2.0/gems/eventmachine-1.2.3/gem_make.out

To fix this, run this command:
sudo yum -y install ruby-devel gcc