How to install Java 9 (JDK 9, JRE 9) on Linux
Installing JDK 9 in Ubuntu, Linux Mint, Debian, Kali Linux
In Linux repositories (application sources), OpenJDK is usually present - this is a Java implementation from the community. If you prefer a proprietary version from Sun Microsystems (Oracle Corporation), then it must be installed from the official website.
Let's start with the version check:
java -version
The output can be:
openjdk version "1.8.0_151" OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-1-b12) OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
As you can understand from the records, OpenJDK is installed.
If Java is not installed at all, it will display:
The 'java' application can be found in the following packages: * default-jre * gcj-5-jre-headless * openjdk-8-jre-headless * gcj-4.8-jre-headless * gcj-4.9-jre-headless * openjdk-9-jre-headless Try: sudo apt install <selected package>
To install the JDK, run the following commands in sequence:
sudo su - mkdir -p /opt/java && cd /opt/java
Java 9 is only available for 64-bit systems. To install it, run the command:
curl -s http://www.oracle.com/`curl -s http://www.oracle.com/technetwork/java/javase/downloads/index.html | grep -o -E '/technetwork/java/javase/downloads/jdk9-downloads-[0-9]{1,10}.html' | head -n 1` | grep -o -E 'http://download.oracle.com/otn-pub/java/jdk/[a-z0-9.+_/-]{4,}linux-x64_bin.tar.gz' | tail -n 1 > temp; wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "`cat temp`"; rm temp
Extract and rename the archive:
tar -zxvf jdk-*.tar.gz && rm *.tar.gz && mv jdk* jdk-9
Next, use the update-alternatives command to tell the system where Java and its executable files are installed.
cd jdk-9 update-alternatives --install /usr/bin/java java /opt/java/jdk-9/bin/java 100 update-alternatives --config java
Choose the option with /opt/java/jdk-9/bin/java
Also a message can be displayed:
There is only one alternative in link group java (providing /usr/bin/java): /opt/java/jdk-9/bin/java Nothing to configure.
In this case, everything is all right too, you do not need to customize anything else.
Let's say the system update the javac (Java compiler) alternatives as follows:
update-alternatives --install /usr/bin/javac javac /opt/java/jdk-9/bin/javac 100 update-alternatives --config javac
The system can write that there is only one alternative - this is also normal.
In a similar way, we update jar alternatives like this:
update-alternatives --install /usr/bin/jar jar /opt/java/jdk-9/bin/jar 100 update-alternatives --config jar
Again, there may be only one alternative, if there are several, then again select the one that /opt/java/jdk-9/bin/java.
Configure Java environment variables.
Run in the console:
export JAVA_HOME=/opt/java/jdk-9/ export JRE_HOME=/opt/java/jdk-9/jre export PATH=$PATH:/opt/java/jdk-9/bin:/opt/java/jdk-9/jre/bin
After a reboot, the environment variables will be reset. To avoid entering these values each time after a reboot, you can edit one of the three files:
$HOME/.bashrc
OR
$HOME/.profile
OR
/etc/profile
It is recommended that you select /etc/profile, because in this case the settings will be available to all users of the system. Open this file:
gedit /etc/profile
And add at the very end of the file:
export JAVA_HOME=/opt/java/jdk-9/ export JRE_HOME=/opt/java/jdk-9/jre export PATH=$PATH:/opt/java/jdk-9/bin:/opt/java/jdk-9/jre/bin
To be sure, we'll check the Java version again.
java -version
Output:
java version "9.0.1" Java(TM) SE Runtime Environment (build 9.0.1+11) Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)
Related articles:
- How to install NetBeans 9 for JDK 9 development (99%)
- testssl.sh: No cipher mapping file found and No TLS data file found (SOLVED) (52.7%)
- How to Install Total Commander Counterpart in Kali Linux (52.7%)
- How to install Intercepter-NG in Linux (52.7%)
- How to install VeraCrypt on Linux (52.7%)
- Why 404 errors are not saved in Apache error log (RANDOM - 50%)
thanks