1. Download JDK
Address: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
2. Unzip the file you just downloaded to the/USR/LIB/JVM folder, and if you don't have the folder, you can create a new folder
Cp-r/home/xx/Download/JDK1.8.0_25/USR/LIB/JVM
3. Configure Environment variables
Typing command:
gedit~/. BASHRCon the last add:
1234 |
ExportJava_home=/usr/Lib/JVM/jdk1.8.0_25ExportJre_home=${Java_home}/JREExportCLASSPATH=.:${Java_home}/Lib:${Jre_home}/LibExport PATH=${Java_home}/bin:$PATH |
Save exit, enter the following command to make the environment variable of this configuration take effect
4. Configure the default JDK version and execute the following commandsudoUpdate-Alternatives--Install/usr/Li/JavaJava/usr/Lib/JVM/jdk1.8.0_25/bin/Java -sudoUpdate-Alternatives--Install/usr/bin/JavacJavac/usr/Lib/JVM/jdk1.8.0_25/bin/Javac -5. TestingOpen a terminal input dimly command java-version
Outputjava Version "1.8.0_25"
Java (TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot (TM) Server VM (build 25.25-b02, Mixed mode)
indicates a successful test.
Linux installation JDK 8 and environment variable configuration