Because of the different Linux developers, so different developers of Linux version operation details are not the same, today, the installation of CentOS under the JDK:
Method One: Manually unzip the JDK's tarball and set the environment variable
1. Create a Java directory under the/usr/directory
mkdir/usr/~]# Cd/usr/java
2. Download the JDK, then unzip
[Email protected] java]# Curl-o http://tar -zxvf jdk-7u79-linux-x64. tar. gz
3. Setting Environment variables
VI /etc/profile
In profile, add the following:
#set java environmentjava_home=/usr/java/jdk1. 7 . 0_79jre_home=/usr/java/jdk1. 7. 0_79/Jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/LibPATH = $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH
Let the changes take effect:
[Email protected] java]# Source/etc/profile
4. Verifying JDK Validity
[Email protected] java]# java-"1.7.0_79"1.7. 0_79- - 24.79-b02, Mixed mode)
Method Two: Install the JDK with Yum
1. See which JDK versions are available in the Yum Library (OPENJDK only)
[Email protected] ~]#YumSearch java|grepJDKLDAPJDK-javadoc.x86_64:javadoc forLdapjdkjava-1.6.0-Openjdk.x86_64:OpenJDK Runtime Environmentjava-1.6.0-openjdk-Demo.x86_64:OpenJDK Demosjava-1.6.0-openjdk-Devel.x86_64:OpenJDK Development Environmentjava-1.6.0-openjdk-Javadoc.x86_64:OpenJDK API Documentationjava-1.6.0-openjdk-Src.x86_64:OpenJDK Source Bundlejava-1.7.0-Openjdk.x86_64:OpenJDK Runtime Environmentjava-1.7.0-openjdk-Demo.x86_64:OpenJDK Demosjava-1.7.0-openjdk-Devel.x86_64:OpenJDK Development Environmentjava-1.7.0-openjdk-Javadoc.noarch:OpenJDK API Documentationjava-1.7.0-openjdk-Src.x86_64:OpenJDK Source Bundlejava-1.8.0-Openjdk.x86_64:OpenJDK Runtime Environmentjava-1.8.0-openjdk-Demo.x86_64:OpenJDK Demosjava-1.8.0-openjdk-Devel.x86_64:OpenJDK Development Environmentjava-1.8.0-openjdk-Headless.x86_64:OpenJDK Runtime Environmentjava-1.8.0-openjdk-Javadoc.noarch:OpenJDK API Documentationjava-1.8.0-openjdk-Src.x86_64:OpenJDK Source Bundleldapjdk.x86_64:The Mozilla LDAP Java SDK
2. Select a version to install
// Select version 1.7 to install Yum Install java-1.7. 0-openjdk
After the installation is complete, the default installation directory is:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.75.x86_64
3. Setting Environment variables
VI /etc/profile
Add the following content to the profile file
#set java environmentjava_home=/usr/lib/jvm/java-1.7. 0-openjdk-1.7. 0.75 . X86_64jre_home= $JAVA _home/jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar:$ jre_home/LibPATH= $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH
Let the changes take effect
[Email protected] java]# Source/etc/profile
4. Verification (Ibid. method)
Method Three: Install the JDK with rpm
1. Download RPM installation files
[Email protected] ~]$ Curl-o http://download.oracle.com/otn-pub/java/jdk/7u79-b15/ jdk-7u79-linux-x64.rpm
2. Installing using the RPM command
[Email protected] ~]# RPM-IVH jdk-7u79-linux-x64.rpm
3. Setting Environment variables
VI /etc/profile
Add the following in the open profile file
#set java environmentjava_home=/usr/java/jdk1. 7 . 0_79jre_home=/usr/java/jdk1. 7. 0_79/Jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar: $JRE _home/LibPATH = $PATH: $JAVA _home/bin: $JRE _home/binexport java_home jre_home class_path PATH
Let the changes take effect
[Email protected] java]# Source/etc/profile
4. Verification (Ibid. method)
Note: Similar to yum installation, you can run Java commands without setting environment variables. The RPM installation method installs the JDK to/usr/java/jdk1.7.0_79 by default, and then links to/usr/bin via a three-layer link, as follows:
[[Email protected] ~]# CD/Bin[[email protected] bin]# ll|grepjavalrwxrwxrwx.1Root root -Mar - One: -Jar->/usr/java/default/bin/jarlrwxrwxrwx.1Root root -Mar - One: -Java-/usr/java/default/bin/javalrwxrwxrwx.1Root root -Mar - One: -Javac->/usr/java/default/bin/javaclrwxrwxrwx.1Root root inMar - One: -Javadoc->/usr/java/default/bin/javadoclrwxrwxrwx.1Root root -Mar - One: -Javaws->/usr/java/default/bin/javawslrwxrwxrwx.1Root root -Mar - One: -Jcontrol->/usr/java/default/bin/Jcontrol[[email protected] bin]# CD/usr/java/[email protected] java]# lltotal4lrwxrwxrwx.1Root root -Mar - One: -Default->/usr/java/LATESTDRWXR-xr-x.8Root root4096Mar - One: -Jdk1.7. 0_79lrwxrwxrwx.1Root root +Mar - One: -Latest,/usr/java/jdk1.7.0_79
Method Four: Install JDK on Ubuntu using Apt-get
1. See which JDK versions are available in the APT library
[Email protected]:~# apt-cache Search java|grepJdkdefault-JDK-Standard Java or Java compatible development Kitdefault-jdk-doc-Standard Java or Java Compatible development Kit (documentation) GCJ-4.6-JDK-GCJ and Classpath Development tools forJava (TM) gcj-JDK-GCJ and Classpath Development tools forJava (TM) openjdk-6-DBG-Java Runtime based on OpenJDK (debugging symbols) OpenJDK-6-demo-Java Runtime based on OpenJDK (demos and examples) OpenJDK-6-doc-OpenJDK Development Kit (JDK) documentationopenjdk-6-JDK-OpenJDK Development Kit (JDK) OpenJDK-6-jre-lib-OpenJDK Java Runtime (architecture Independent libraries) OpenJDK-6-source-OpenJDK Development Kit (JDK) source Filesopenjdk-7-DBG-Java Runtime based on OpenJDK (debugging symbols) OpenJDK-7-demo-Java Runtime based on OpenJDK (demos and examples) OpenJDK-7-doc-OpenJDK Development Kit (JDK) documentationopenjdk-7-JDK-OpenJDK Development Kit (JDK) OpenJDK-7-source-OpenJDK Development Kit (JDK) source Filesuwsgi-plugin-jvm-openjdk-6-Java Plugin forUwsgi (OpenJDK6) Uwsgi-plugin-jwsgi-openjdk-6-Jwsgi Plugin forUwsgi (OpenJDK6) OpenJDK-6-JRE-OpenJDK Java Runtime, using Hotspot jitopenjdk-6-jre-headless-OpenJDK Java Runtime, using Hotspot JIT (headless) OpenJDK-7-JRE-OpenJDK Java Runtime, using Hotspot jitopenjdk-7-jre-headless-OpenJDK Java Runtime, using Hotspot JIT (headless) OpenJDK-7-JRE-LIB-OPENJDK Java Runtime (architecture Independent libraries)
2. Select a version to install
Install openjdk-7-jdk
3. Setting Environment variables
VI /etc/profile
Add the following in the open profile file
#set java environmentjava_home=/usr/lib/jvm/java-1.7. 0-openjdk-amd64jre_home= $JAVA _home/jreclass_path=.: $JAVA _home/lib/dt.jar: $JAVA _home /lib/tools.jar: $JRE _home/LibPATH= $PATH: $JAVA _home/bin: $JRE _home/binexport java_homejre_home Class_ Path Path
Let the changes take effect
[Email protected]:~# source/etc/profile
4. Verification (Ibid. method)
Three ways to install JDK under CentOS