Open Terminal:
Ctrl+alt+t
Download JDK:
wget http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.tar.gz
Decompression jdk-8u144-linux-x64.tar.gz:
Tar zxvf jdk-8u144-linux-x64.tar.gz
cut to the JDK directory:
MV jdk-8u144-linux-x64 /data/service/jdk/
Set the Java environment variable (using the VIM command):
Vim/etc/profile
Add 4 rows of variables after the open vim:
Export Java_home=/data/service/jdk
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH
re-configuration:
vim/etc/profile.d/java-env.sh
Add 2 rows of variables to the open vim:
Export JAVA_HOME=/DATA/SERVICE/JDK
Export path= $PATH: $JAVA _home/bin
Execution Environment variables:
Source/etc/profile
Source /etc/profile.d/java-env.sh
To view the JDK:
Echo $JAVA _home
Echo $PATH
To detect the JDK and view the JDK version:
Java-version
then create a Helloword.java file at random to test whether the JDK was installed successfully:
public void Helloword {
public static void Main (string[] args) {
System.out.println ("Helloword");
}
}
then enter in the terminal:
cd/media/user name/partition/
Javac Helloword.java will generate the Hellword.class file in the/partition drive letter.
Java Helloword If the terminal displays Helloword then install the JDK successfully!.
Ubuntu16.04 Install jdk-8u144-linux-x64.tar.gz