JDK Installation (i)

Source: Internet
Author: User

1, first uninstall the server's own JDK package
# java-version #查看服务器是否安装过jdk
Java Version "1.6.0_17"
OpenJDK Runtime Environment (IcedTea6 1.7.4) (rhel-1.21.b17.el6-i386)
OpenJDK Client VM (build 14.0-b16, Mixed mode)
# Rpm-qa |grep gcj #查看服务器安装的jdk软件包信息
libgcj-4.4.4-13.el6.i686
java-1.5.0-gcj-1.5.0.0-29.1.el6.i686
# rpm-e java-1.5.0-gcj-1.5.0.0-29.1.el6.i686 #卸载软件包

2, to the Sun's official website download

Http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
Select Accept License and select the JDK download that fits your model.

3, unzip the file, modify the filename

$ sudo MKDIR/USR/LIB/JVM
$ sudo tar zxvf jdk-7u21-linux-i586.tar.gz-c/USR/LIB/JVM
$ CD/USR/LIB/JVM
$ sudo mv jdk1.7.0_21 Java


4. Add Environment variables

$ sudo vim ~/.BASHRC
Add the following:

Export Java_home=/usr/lib/jvm/java
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib
Export Path=${java_home}/bin: $PATH


5. Configuring the default JDK version

sudo update-alternatives--install/usr/bin/java Java/usr/lib/jvm/java/bin/java 300
sudo update-alternatives--install/usr/bin/javac Javac/usr/lib/jvm/java/bin/javac 300
sudo update-alternatives--install/usr/bin/jar Jar/usr/lib/jvm/java/bin/jar 300
sudo update-alternatives--install/usr/bin/javah javah/usr/lib/jvm/java/bin/javah 300
sudo update-alternatives--install/usr/bin/javap JAVAP/USR/LIB/JVM/JAVA/BIN/JAVAP 300
And then execute

sudo update-alternatives--config java
If you first install the JDK, you will be prompted

There is only one alternative in link Group Java (providing/usr/bin/java):/usr/lib/jvm/java/bin/java
No configuration required.
For non-initial installation, there will be different versions of the JDK option.

6. Testing

$ java-version
Java Version "1.7.0_21"
Java (TM) SE Runtime Environment (build 1.7.0_21-B11)
Java HotSpot (TM) Server VM (build 23.21-b01, Mixed mode)

JDK Installation (i)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.