Tuesday 20 August 2019

java - Unsupported major.minor version 52.0

You need to upgrade your Java version to Java 8.


For 64 bit


 # cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-x64.tar.gz"
# tar xzf jdk-8u51-linux-x64.tar.gz

For 32 bit


 # cd /opt/
# wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u51-b16/jdk-8u51-linux-i586.tar.gz"
# tar xzf jdk-8u51-linux-i586.tar.gz

Note: If the above wget command doesn’t not work for you, watch this example video to download the Java source archive using the terminal.


After extracting the archive file, use the alternatives command to install it. The alternatives command is available in the chkconfig package.


 # cd /opt/jdk1.8.0_51/
# alternatives --install /usr/bin/java java /opt/jdk1.8.0_51/bin/java 2
# alternatives --config java

At this point Java 8 has been successfully installed on your system. We also recommend to setup javac and jar commands path using alternatives:


 # alternatives --install /usr/bin/jar jar /opt/jdk1.8.0_51/bin/jar 2
# alternatives --install /usr/bin/javac javac /opt/jdk1.8.0_51/bin/javac 2
# alternatives --set jar /opt/jdk1.8.0_51/bin/jar
# alternatives --set javac /opt/jdk1.8.0_51/bin/javac

Check the installed version of Java using the following command.


root@tecadmin ~# java -version
java version "1.8.0_51"
Java(TM) SE Runtime Environment (build 1.8.0_51-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.51-b03, mixed mode)

Most of Java-based applications use environment variables to work. Set the Java environment variables using the following commands:


Setup JAVA_HOME Variable


# export JAVA_HOME=/opt/jdk1.8.0_51
Setup JRE_HOME Variable
# export JRE_HOME=$JAVA_HOME/jre
Setup PATH Variable
# export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

Note that the change to the PATH variable put the new Java bin folders first so that they override any existing java/bins in the path. It is a bit sloppy to leave two java/bin folders in your path so you should be advised to clean those up as a separate task.


Also, put all above environment variables in the /etc/environment file for auto loading on system boot.

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...