步骤1:下载JDK 1.7 安装包
JDK 1.7 下载地址:http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html
在下载过程中,需要注意两点:
1:注意操作系统版本,以及32位还是64位操作系统。如下所示,Linux 分x86、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:检查Linux 系统上是否存在其它版本的JDK,如果有则先卸载旧版本的JKD。
[[email protected] /]# java -version java 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 NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
查看自带的JDK的相关信息
[[email protected] ~]# rpm -qa | grep gcj[jdk][java] libgcj-4.1.2-51.el5 java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 libgcj-4.1.2-51.el5
卸载自带的JDK的信息
[[email protected] /]# rpm -e --nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
步骤3:解压安装JDK
RPM 包安装
[[email protected] java]# chmod +x jdk-7u25-linux-x64.rpm [[email protected] java]# 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包安装
[[email protected] usr]# mkdir java [[email protected] java]# tar -xzvf jdk-7u25-linux-x64.tar.gz
步骤4:配置环境变量
在etc/profile文件下添加
export JAVA_HOME=/usr/java/jdk1.7.0_25 export CLASSPATH=/usr/java/jdk1.7.0_25/lib export PATH=$JAVA_HOME/bin:$PATH
如果你不想重新系统,可以用命令source /etc/profile使配置文件立即生效。否则只能重启系统才能使配置参数生效。
[[email protected] ]# source /etc/profile
验证环境变量是否生效
[[email protected] ~]# echo $JAVA_HOME /usr/java/jdk1.7.0_25 [[email protected] ~]# 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 [[email protected] ~]# echo echo $CLASSPATH /usr/java/jdk1.7.0_25/lib [[email protected] ~]#
步骤5:验证安装成功与否,以及环境变量是否生效
[[email protected] 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)
时间: 2024-11-25 05:57:41