Install JDK and environment variable configuration under Linux Centos7 __linux

Source: Internet
Author: User

Step One: View and uninstall the OPENJDK from CentOS

# installed CentOS will bring openjdk, with command Java-version, will have the following information:
[root@localhost ~]# java-version
java Version "1.6.0"
OpenJDK Runtime Environment (build 1.6.0-b09)
OpenJDK 64-bit Server VM (build 1.6.0-b09, Mixed mode)

# It's best to uninstall Ope first NJDK, installing the Sun's JDK. First Check Rpm-qa | grep Java
Displays the following information:
   java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
   Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

Uninstall:
rpm-e--nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
rpm-e--nodeps Java-1.6.0-openjdk-1.6.0.0-1.7.b09.el5

also has a few other commands:
Rpm-qa | grep gcj
RPM-QA | grep jdk

If there is no ope found NJDK source, then you can also uninstall:
yum-y remove Java java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
yum-y remove Java java- 1.6.0-openjdk-1.6.0.0-1.7.b09.el5

The second step: first to the official website to download JDK. http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html, I download jdk-7u45-linux-x64.tar.gz, download to the home directory.

Step Three: Unpack the source pack

# Create a new Java folder in the/usr/local directory via the terminal, command line:
sudo mkdir/usr/local/java

# then copy the download to the compressed package to the Java folder, command line: Go to the directory
where the JDK source package resides CP Jdk-7u45-linux-x64.tar.gz/usr/local/java

# then go to the Java directory, command line:
Cd/usr/local/java

# Unzip the zip package, command line:
sudo Tar xvf jdk-7u45-linux-x64.tar.gz

# Then you can delete the compression package, command line:
sudo rm jdk-7u45-linux-x64.tar.gz


Fourth Step: Set JDK environment variables

# Here is the global setting method, which is to modify the Etc/profile, which is the shared environment variable for all users
Gedit/etc/profile

# opened to add export at the end
java_home=/usr/ local/java/jdk1.7.0_79
export classpath=.: $JAVA _home/jre/lib/rt.jar: $JAVA _home/lib/dt.jar: $JAVA _home/lib/ Tools.jar
export path= $PATH: $JAVA _home/bin

# Remember, in the above add process, do not add a space on either side of the equal sign, otherwise "not valid identifier" will appear
because source/etc/ Profile does not recognize redundant to spaces, will be understood as a path part. Then save the
source/etc/profile


Step Fifth: Verify that the installation is successful

# in the terminal
java-version to

see if the successful installation
will display the following
Java version "1.7.0_45"
Java (TM) SE Runtime Environment (Build 1.7.0_45-b18)
Java HotSpot (TM) 64-bit Server VM (build 24.45-b08, Mixed mode)
Related Article

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.