1、先检查linux机器上是否有自带的jdk,如果有版本低的话可以先卸载掉,方法如下:
[root@localhost java]# rpm -qa|grep gcj 或者 rpm -qa|grep java
libgcj-4.1.2-44.el5
java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
如果没有信息就是没有安装、如果有那么如下操作
[root@localhost jdk-6u13-linux-i586]# yum -y remove java-1.4.2-gcj-compat-1.4.2.0-40jpp.115 或者 rpm -e –nodeps java-1.4.2-gcj-compat-1.4.2.0-40jpp.115
Loaded plugins: rhnplugin, security
This system is not registered with RHN.
RHN support will be disabled.
Setting up Remove Process
Resolving Dependencies
–> Running transaction check
—> Package java-1.4.2-gcj-compat.i386 0:1.4.2.0-40jpp.115 set to be erased
–> Processing Dependency: java-gcj-compat for package: antlr
–> Processing Dependency: java-gcj-compat for package: antlr
–> Processing Dependency: java-gcj-compat >= 1.0.64 for package: gjdoc
–> Processing Dependency: java-gcj-compat >= 1.0.64 for package: gjdoc
–> Running transaction check
—> Package antlr.i386 0:2.7.6-4jpp.2 set to be erased
—> Package gjdoc.i386 0:0.7.7-12.el5 set to be erased
–> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Removing:
java-1.4.2-gcj-compat i386 1.4.2.0-40jpp.115 installed 441
Removing for dependencies:
antlr i386 2.7.6-4jpp.2 installed 2.5 M
gjdoc i386 0.7.7-12.el5 installed 1.7 M
Transaction Summary
================================================================================
Install 0 Package(s)
Update 0 Package(s)
Remove 3 Package(s)
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Erasing : antlr [1/3]
Erasing : gjdoc [2/3]
Erasing : java-1.4.2-gcj-compat [3/3]
Removed: java-1.4.2-gcj-compat.i386 0:1.4.2.0-40jpp.115
Dependency Removed: antlr.i386 0:2.7.6-4jpp.2 gjdoc.i386 0:0.7.7-12.el5
Complete!(至此,卸载完成)
2、安装自己的jdk,这里下载的是rpm包
下载地址
http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html
接着执行安装
[root@localhost local]# rpm -ivh jdk-7-linux-i586.rpm
Preparing… ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files…
rt.jar…
jsse.jar…
charsets.jar…
tools.jar…
localedata.jar…
plugin.jar…
javaws.jar…
deploy.jar…
rpm包安装完毕。
3、配置环境变量
#vi /etc/profile
在该profile文件中最下面添加:
JAVA_HOME=/usr/java/jdk1.7.0//自己的jdk路径
JRE_HOME=/usr/java/jdk1.7.0/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/jt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
添加完毕保存退出
source /etc/profile
[root@localhost jdk1.7.0]# java -version
java version “1.7.0”
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode, sharing)
[root@localhost jdk1.7.0]# echo $JAVA_HOME
/usr/java/jdk1.7.0
至此,jdk就安装、配置完毕。

作者 admin

发表评论

您的电子邮箱地址不会被公开。