CentOS6.4 install and configure JDK7
Installation instructions
System Environment: centos-6.4
Installation Method: rpm Installation
Software: jdk-7-linux-x64.rpm
: Http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
Check the original system version
[Root @ admin ~] # Java-version
Java version "1.6.0 _ 24"
OpenJDK Runtime Environment (IcedTea6 1.11.1) (rhel-1.45.1.11.1.el6-x86_64)
OpenJDK 64-Bit Server VM (build between 0-b12, mixed mode)
To further view the JDK information:
[Root @ admin ~] # Rpm-qa | grep java
Tzdata-java-2012c-1.el6.noarch
Java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64
Uninstall OpenJDK and perform the following operations:
[Root @ admin ~] # Rpm-e -- nodeps tzdata-java-2012c-1.el6.noarch
[Root @ admin ~] # Rpm-e -- nodeps java-1.6.0-openjdk-1.6.0.0-1.45.1.11.1.el6.x86_64Install JDK
Upload new jdk-7-linux-x64.rpm software to/usr/local/to perform the following operations:
[Root @ admin local] # rpm-ivh jdk-7-linux-x64.rpm
JDK is installed in/usr/java by default.
Verify Installation
Perform the following operations to check whether the information is normal:
[Root @ admin bin] # java
[Root @ admin bin] # javac
[Root @ admin bin] # java-version
Java version "1.7.0"
Java (TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot (TM) 64-Bit Server VM (build 21.0-b17, mixed mode)
Congratulations! The installation is successful!
Configure Environment Variables
After installing the jdk-7-linux-x64.rpm on my machine, I can still perform the javac and java-version operations without configuring environment variables, so I didn't configure JDK environment variables. However, for future discomfort, we should record how to configure it as follows:
Modify the system environment variable File
Vi +/etc/profile
Append the following content to the file:
JAVA_HOME =/usr/java/jdk1.7.0
JRE_HOME =/usr/java/jdk1.7.0/jre
PATH = $ PATH: $ JAVA_HOME/bin: $ JRE_HOME/bin
CLASSPATH =.: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/tools. jar: $ JRE_HOME/lib
Export JAVA_HOME JRE_HOME PATH CLASSPATH
Make the modification take effect
[Root @ admin local] # source/etc/profile // make the modification take effect immediately
[Root @ admin local] # echo $ PATH // view the PATH value