Install JDK on Linux and jdk on linux
Step 1:Download the JDK 1.7 installation package
JDK 1.7: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
During the download process, pay attention to the following two points:
1: Pay attention to the operating system version and 32-bit or 64-bit operating system. Linux is divided into 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 |
Step 2:Check whether another version of JDK exists in Linux. If any, uninstall the old version of JKD first.
[root@localhost /]# java -versionjava version "1.4.2"gij (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 NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
View the built-in JDK Information
[root@getlnx06 ~]# rpm -qa | grep gcj[jdk][java]libgcj-4.1.2-51.el5java-1.4.2-gcj-compat-1.4.2.0-40jpp.115libgcj-4.1.2-51.el5
Uninstall built-in JDK Information
[root@localhost /]# rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Step 3:Decompress and install JDK
RPM package installation
[root@localhost java]# chmod +x jdk-7u25-linux-x64.rpm[root@localhost java]# rpm -ivh jdk-7u25-linux-x64.rpmPreparing... ########################################### [100%]1:jdk ########################################### [100%]Unpacking JAR files...rt.jar...jsse.jar...charsets.jar...tools.jar...localedata.jar...
Tar package installation
[root@localhost usr]# mkdir java[root@localhost java]# tar -xzvf jdk-7u25-linux-x64.tar.gz
Step 4:Configure Environment Variables
Add it under the etc/profile file
export JAVA_HOME=/usr/java/jdk1.7.0_25export CLASSPATH=/usr/java/jdk1.7.0_25/libexport PATH=$JAVA_HOME/bin:$PATH
If you do not want to restart the system, run the source/etc/profile command to make the configuration file take effect immediately. Otherwise, you can only restart the system to make the configuration parameters take effect.
[root@localhost ]# source /etc/profile
Verify that environment variables take 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 5:Verify whether the installation is successful and whether the environment variables take effect
[root@localhost tmp]# java -versionjava 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)