Redhat Linux install JDK 1.7

This article mainly introduces the installation of JDK 1.7 on Redhat Linux (Red Hat Enterprise Linux Server release 5.7 (Tikanga)) system. The installation of other Linux platforms is similar, and there may be slight differences.

Step 1: Download the JDK 1.7 installation package

JDK 1.7 download address: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html

 

During the download process, you need to pay attention to two points:

1: Pay attention to the operating system version, and whether it is a 32-bit or 64-bit operating system. As shown below, Linux is divided into two types: x86 and x64.

Product / File Description

File Size

Download

Linux x86

80.38 MB

jdk-7u25-linux-i586.rpm

Linux x86

93.12 MB

jdk-7u25-linux-i586.tar.gz

Linux x64

81.46 MB

jdk-7u25-linux-x64.rpm

Linux x64

91.85 MB

jdk-7u25-linux-x64.tar.gz

2: Pay attention to whether the installation package is in rpm or tar.gz format. rpm is the redhat package, which is the standard installation package of Red Hat, and some Linux systems do not support it. It will be automatically configured during rpm installation. Generally, lib is installed to /urs/bin, and bin is installed to /usr/bin. If it is not installed to /urs/bin, a soft link will also be established in this directory.

 

Step 2: Upload the JKD 1.7 installation package

Under normal circumstances, you can use the FPT tool to upload and install the JDK installation package, because here I use a virtual machine for the experiment, this machine is Win 7 professional version 64-bit operating system, so you must ensure that you can access the files under Windows under Linux. Click "Options" - Shared Folders" under "Virtual Machine Settings", select "Always Enable", and then follow the wizard to set the folders you need to share. Then you can see the JKD file under /mnt/hgfs/ folder, copy the JKD installation package to the ~/tmp/ file.

clip_image002

[root@localhost ~]# cd /mnt/hgfs/

[root@localhost hgfs]# ls

JKD

[root@localhost hgfs]# cd JKD

[root@localhost JKD]# ls

jdk-7u25-linux-x64.rpm jdk-7u25-linux-x64.tar.gz

[root@localhost JKD]#

[root@localhost JKD]# cp jdk-7u25-linux-x64.rpm ~/tmp/

[root@localhost JKD]# cp jdk-7u25-linux-x64.tar.gz ~/tmp/

 

Step 3: Check whether other versions of JDK exist on the Linux system, and if so, uninstall the old version of JKD first.

[root@localhost /]# java -version

java version "1.4.2"

thou (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-51)

Copyright (C) 2006 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

View information about the built-in JDK

[root@getlnx06 ~]# rpm -qa | grep gcj

libgcj-4.1.2-51.el5

java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

libgcj-4.1.2-51.el5

Information about uninstalling the built-in JDK

[root@localhost /]# rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115

 

Step 4: Unzip and install JDK

RPM package installation

[root@localhost tmp]# chmod +x jdk-7u25-linux-x64.rpm

[root@localhost tmp]# rpm -ivh jdk-7u25-linux-x64.rpm

Preparing... ########################################### [100%]

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

Unpacking JAR files...

rt.jar...

jsse.jar...

charsets.jar...

tools.jar...

localedata.jar...

tar package installation

 

Create a new folder /usr/java/

[root@localhost usr]# mkdir java

[root@localhost usr]# cd ~/tmp

[root@localhost tmp]# tar xzvf jdk-7u25-linux-x64.tar.gz -C /usr/java/

 

Step 5: Configure Environment Variables

Add under etc/profile file

export JAVA_HOME=/usr/java/jdk1.7.0_25

export CLASSPATH=/usr/java/jdk1.7.0_25/lib

export PATH=$JAVA_HOME/bin:$PATH

If you don't want to restart the system, you can use the command source /etc/profile to make the configuration file take effect immediately. Otherwise, only restart the system to make the configuration parameters take effect.

[root@localhost ~]# source /etc/profile

Verify that environment variables are in effect

[root@localhost ~]# echo $JAVA_HOME

/usr/java/jdk1.7.0_25

[root@localhost ~]# echo $PATH

/usr/java/jdk1.7.0_25/bin:/usr/kerberos/sbin:/usr/kerberos/bin

:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin

[root@localhost ~]# echo echo $CLASSPATH

/usr/java/jdk1.7.0_25/lib

[root@localhost ~]#

 

Step 6: Verify that the installation was successful and that the environment variables took effect

[root@localhost tmp]# java -version

java version "1.7.0_25"

Java(TM) SE Runtime Environment (build 1.7.0_25-b15)

Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)

Step 7: Delete the JDK installation package in the tmp directory

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326489728&siteId=291194637