Step 1: Download the JDK of tar.gz,
Run the sudo tar zxvf./jdk's name.tar.gz-C and the path you want to specify.
Step 2: Modify JDK Permissions
Sudo chmod 766-r your JDK path
Step 3: Press CTRL + ALT + T to open the terminal
Step 4: Enter sudo gedit/etc/profile, the system will pop up the profile text file, and add the following code at the end
# Set Java environment
Export java_home = Your JDK path
Export jre_home =$ {java_home}/JRE
Export classpath =. :$ {java_home}/lib: 4 {jre_home}/lib
Export path =$ {java_home}/bin: $ path
Step 5: Source/etc/profile is used to re-execute the initial or file you just modified to make it take effect immediately
Step 6: install and use openjdk (usr/lib/JVM/) by default in Ubuntu. Therefore, you must manually modify the default JDK
Sudo Update-alternatives -- install/usr/bin/Java your JDK path/bin/Java 300 sudo Update-alternatives -- install/usr/bin/javac your JDK path/ bin/javac 300 sudo Update-alternatives -- install/usr/bin/Jar your JDK path/bin/jar 300 sudo Update-alternatives -- install/usr/bin/javah you JDK path/bin/javah 300 sudo Update-alternatives -- install/usr/bin/javap your JDK path/bin/javap 300 Step 7, sudo Update-alternatives -- config Java
Step 8: Now the configuration is complete. Enter Java-version, javac, or Java to check whether the configuration is successful.
Ubuntu14.04 configure JDK Environment Variables