First, download
First of all, of course it is to download.
Address: www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Select a different version as needed.
Second, decompression
Unzip the downloaded. tar.gz file.
Use the following command to extract:
Tar zxvf./jdk-7u45-linux-x64. tar.gz
For ease of administration, you can move the extracted files to another folder.
You can do it without doing it.
The author moved the file to the/opt/java/jdk/directory.
To facilitate the next set of environment variables, change the folder to a short name--jdk1.7
You can rename a folder by using the following command
MV Jdk1. 7.0_45/jdk1. 7/
Third, set environment variables
Edit the. bashrc file.
Enter the following command at the terminal:
VI ~/.BASHRC
At the end of the file, add the following lines of code:
Export JAVA_HOME=/OPT/JAVA/JDK/JDK1. 7
Export Jre_home=${java_home}/jreexport classpath=.:${java_home}/lib:${jre_home}/libexport PATH=${JAVA_HOME}/ Bin: $PATH
In order for the changes to take effect immediately, execute the following command at the terminal:
SOURCE ~/.BASHRC
PS: When modifying ~/.BASHRC's path modification error, unable to use the system's other commands, the terminal input is as follows: you can use
Export Path=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/x11:/usr/games
P.S. It is best to back up the backup command before modifying the. bashrc file:
CP. BASHRC. Bash_origina
Build Java JDK Environment under Linux