Environment:
Ubuntu 18.04 LTS x64 bit
System User Hou
Tools:
Jdk-8u171-linux-x64.tar.gz
The heart of the experiment
Steps:
To see if the JDK is installed, press and hold ctr+alt+t to open the command window input java-version
No JDK pops up with the following hint:
[email protected]:~$ java-version
Command ' Java ' not found, but can is installed with:
sudo apt install default-jre
sudo apt install openjdk-11-jre-headless
sudo apt install openjdk-8-jre-headless
Download the Linux version (version tar.gz) JDK to Oracle official website
Move the file jdk-8u65-linux-x64.gz to/home/hou/java, and unzip:
TAR-XZVF jdk-8u171-linux-x64.tar.gz
Create folder Java(I'll put it in the/home/hou/directory where I see it):
Mkdir/home/hou/java
Delete Compressed Package input instruction RM jdk-8u171-linux-x64.tar.gz
[Email protected]:~/java$
Configure environment variables, you can add to all users ' global environment variables under /etc/profile , or you can add Java environment variables for the current user environment variable ~/.BASHRC . Because I use the Ubutu attempt to modify Vi/etc/profile, the profile file is read-only without write permission, I am too lazy to add write permission to the Java environment variable added in the current user's ~/.BASHRC
Open ~/.BASHRC and edit
[email protected]:~/java$ $sudo gedit ~/.BASHRC
Add the following code at the end, note: There are no spaces at the end of the line, and spaces are resolved as paths and errors occur.
#set Java environmentexport java_home=/home/hou/java/jdk1.8. 0_171export jre_home= $JAVA _home/ jreexport CLASSPATH=.: $JAVA _home/lib: $JRE _home/lib: $CLASSPATHexport PATH= $JAVA _home/bin:$ Jre_home/bin: $PATH
As shown, make the environment variable effective immediately after saving
[email protected]:~/java$ Source ~/.BASHRC
Verify that the installation is successful
[email protected]:/$ java-version"1.8.0_171" java (TM) SE Runtime Environment (build 1.8.0_171-B11) Java HotSpot (TM) 64-bit Server VM (build 25.171-b11, mixed mode)
Summarize:
Linux installation Oracle jdk1.8 (UBUTU)