First, environmental description:
Operating system: Linux xx-42.6. -431.23. 3. el6.x86_64 #1:wuyi x86_64x86_64 x86_ gnu/Linux JDK version: Java-1.7. 0-openjdk.x86_64
Second, RPM mode installation:
1, download rpm software package, download here is jdk-7u21-linux-i586.rpm.
Modify file Permissions:
[[Email protected]4chmod755 jdk-7u21-linux-i586.rpm
2. Install using the RPM command:
[[Email protected]4 ~]# RPM-IVH jdk-7u21-linux-i586.rpm
3. Check the installation path:
[[Email protected]4 ~]# rpm-ql JDK
4. Set the JAVA_HOME environment variable and add it to path: Set the way below.
Three, yum mode installation:
1, yum query can install the software:
[[Email protected]4yumgrep JDK
Select the java-1.7.0-openjdk.x86_64 in the list above to install.
2. Yum installation software:
[Email protected]4yuminstall java-1.7. 0-openjdk.x86_64
By the way, java-1.7.0-openjdk-devel.x86_64 also installed.
[Email protected]4yuminstall -y java-1.7. 0-openjdk-devel.x86_64
3. Yum to view installed software:
[Email protected]4yumgrep Jdkjava-1.7. 0-openjdk.x86_64 1:1.7. 0.91-2.6. 2.2 . el6_7 @updates Java-1.7. 0-openjdk-devel.x86_64 1:1.7. 0.91-2.6. 2.2. el6_7 @updates
4. Yum Delete the installed packages:
[Email protected]4yum remove java-1.7. 0-openjdk-devel.x86_64
5, query the path after installation:
[[Email protected]4grep JDK
[Email protected]4 ~]# rpm-ql java-1.7. 0-openjdk-1.7. 0.91-2.6. 2.2. el6_7.x86_64
The JDK is installed under the/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64 path.
6. Set the JAVA_HOME environment variable and add the JDK Bin directory to path.
There are two more common settings, modify/etc/profile or modify the ~/.bash_profile. The former is a global setting, which can control settings at the user level.
Either of the above options, add the following to the file:
Export java_home="/usr/lib/jvm/jre-1.7.0-openjdk.x86_64"export PATH= $JAVA _ Home/bin: $PATH
7. View the JDK version:
[[Email protected]4 ~]# java-version
Multiple ways to install JDK under Linux