CentOS 6.8 Installation JDK1.7

Source: Internet
Author: User
Check to see if the Linux system has JDK installed

[root@linux1 ~]# rpm-qa | grep java

tzdata-java-2016c-1.el6.noarch

java-1.6.0-openjdk-1.6.0.38-1.13.10.4.el6.x86_64

java-1.7.0-openjdk-1.7.0.99-2.6.5.1.el6.x86_64

Uninstall the system with its own Java

[root@linux3 ~]# rpm-qa | grep java | xargs rpm-e--nodeps

View Uninstall results

[root@linux3 ~]# java-version

bash:/usr/bin/java:no such file or directory

uninstall succeeded
Download links for various historical versions of Java: Http://download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz? authparam=1521384623_73e629f3cfd12c4b38b8a705405f5974
Download JDK
wget get address, command as follows:
wget--no-check-certificate--no-cookies--header "Cookie:oraclelicense=accept-securebackup-cookie" http:// Download.oracle.com/otn/java/jdk/7u80-b15/jdk-7u80-linux-x64.tar.gz? authparam=1514647148_4deb02bdc334d35818d4a0ba91b4f311
http://www.Oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

jdk-7u79-linux-x64.rpm

Jdk-7u79-linux-x64.tar.gz
The first method: RPM Package Installation

RPM package import user root directory

[root@linux2 ~]# ls

anaconda-ks.cfg  id_dsa.pub  install.log  Install.log.syslog 

jdk-7u79-linux-x64.rpm

granted permission

[root@linux2 ~]# chmod 755

installation

[Root@linux2 ~]# RPM-IVH jdk-7u79-linux-x64.rpm

preparing ...                ########################################### [100%]

1:jdk                    ########################################### [ 100%]

unpacking JAR files ...

Rt.jar ...

Jsse.jar ...

Charsets.jar ...

Tools.jar ...

Localedata.jar ...

Jfxrt.jar ... Installation Complete
The second method: Binary package installation

set up Java_home directory

[root@linux3 ~]# mkdir/usr/java

put binary packages under/usr/java/and unzip

[Root@linux3 ~]# MV Jdk-7u79-linux-x64.tar.gz/usr/java

[root@linux3 ~]# cd/usr/java

[root@linux3 java]# tar xvf jdk-7u79-linux-x64.tar.gz

View Results

[root@linux3 java]# ls

jdk1.7.0_79  jdk-7u79-linux-x64.tar.gz

to save space, you can delete

a binary package [Root@linux3 java]# RM-RF jdk-7u79-linux-x64.tar.gz
Configure the global Java environment variable

[root@linux3 java]# vi/etc/profile

add

export java_home=/usr/java/jdk1.7.0_79

to the last surface Export jre_home= $JAVA _home/jre

export path= $PATH: $JAVA _home/bin

export classpath=./: $JAVA _home/lib:$ Java_home/jre/lib

Save exit to

make profile configuration effective

[Root@linux3 java]# Source/etc/profile
Check the environment variable

[root@linux3 java]# echo $JAVA _home

/usr/java/jdk1.7.0_79

[root@linux3 java]# Echo $CLASSPATH

./:/usr/java/jdk1.7.0_79/lib:/usr/java/jdk1.7.0_79/jre/lib

[Root@linux3 java]# echo $PATH

/usr/local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/ local/cmake-2.8.10.2/bin:/usr/local/mysql/bin:/usr/local/mysql/lib:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/ Local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.7.0_79/bin:/usr/java/jdk1.7.0_79/bin

Installation Complete

Finally, test the installed JDK

[Root@linux3 java]# java-version

java Version "1.7.0_79"

Java (TM) SE Runtime Environment (build 1.7.0_79-b15) C11/>java HotSpot (TM) 64-bit Server VM (build 24.79-b02, Mixed mode)

or input Javac


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.