Before installing, check that the system has a JDK installed
Rpm-qa | grep java
If you can use Rpm-qa | grep Java | Xargs rpm-e--nodeps bulk unload all files with Java
Download on official website
1.
Http://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase7-521261.html
Installation:
RPM (Recommended with RPM package installation):
1. Copy the RPM package to the/usr/java path
Mkdir/usr/java
CP jdk-7u55-linux-x64.rpm/usr/java/
2. Add executable permissions and install:
cd/usr/java/
chmod +x jdk-7u55-linux-x64.rpm
RPM-IVH jdk-7u55-linux-x64.rpm
[Email protected] src]# RPM-IVH jdk-7u55-linux-x64.rpm
Preparing ... ########################################### [100%]
1:JDK ########################################### [100%]
Unpacking JAR files ...
Rt.jar ...
Jsse.jar ...
Charsets.jar ...
Tools.jar ...
Localedata.jar ...
Jfxrt.jar ...
RPM package installation is automatically extracted to the/usr/java/directory:
[Email protected] ~]# cd/usr/java/
[email protected] java]# LL
Total Dosage 4
lrwxrwxrwx 1 root root 16 January, default--/usr/java/latest
Drwxr-xr-x 8 root root 4096 January jdk1.7.0_55
lrwxrwxrwx 1 root root 21 January latest-/usr/java/jdk1.7.0_55
3. Configure Environment variables
Law One:
To edit a profile:
Vim/etc/profile
At the end of the profile file, append the following:
Export java_home=/usr/java/jdk1.7.0_55
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
Save and exit, execute
Source/etc/profile
Law II:
vim/etc/profile.d/java.sh
Exportjava_home=/usr/java/jdk1.8.0_40
Exportpath= $JAVA _home/bin: $PATH
Exportclasspath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
source/etc/profile.d/java.sh
4. View Java version
[Email protected] ~]# java-version
Java Version "1.7.0_55"
Java (TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot (TM) 64-bit Server VM (build 24.55-b03, Mixed mode)
[email protected] ~]# which Java
/usr/bin/java
[Email protected] ~]# Ls-lrt/usr/bin/java
lrwxrwxrwx 1 root root 26 January 06:00/usr/bin/java-/usr/java/default/bin/java
tar.gz
1: Download the JDK Package: This chapter uses a file with the suffix tar.gz (no installation required), such as jdk-7u80-linux-x64.tar.gz
2: Save the JDK file to the Linux directory: Use the mkdir command to generate the/usr/java directory from the console, and put the file under it
3: Unzip the tar.gz file: Through the console, enter the/usr/java, execute, unzip it
4: Configure Environment variables: Open the console, run Vi/etc/profile, insert the content you want to configure at the end, press ESC, enter (: Wq Save and exit)
Export java_home=/usr/java/jdk1.7.0_80
Export path= $JAVA _home/bin: $PATH
Export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar
5: Run Source/etc/profile to make the configuration environment effective
6: Run java-version See if it takes effect. If the JDK version number appears, install and configure the environment variable successfully
How Linux looks at the JDK installation path
1:echo $JAVA _home
If you use $java_home, you can locate the installation path of the JDK as long as the environment variable $java_home is configured, otherwise the installation path of the JDK is not located at all.
650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/8E/58/wKiom1i-K47Q34zbAAAk2KP-gS4754.png-wh_500x0-wm_ 3-wmp_4-s_245535227.png "title=" ~%vbh}1[rvffc@) ~24gsd}d.png "alt=" Wkiom1i-k47q34zbaaak2kp-gs4754.png-wh_50 "/>
[Email protected] ~]# java-version
Java Version "1.7.0_55"
Java (TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot (TM) 64-bit Server VM (build 24.55-b03, Mixed mode)
[Email protected] ~]# echo $JAVA _home
Installing JDK under Linux