redhat配置java环境

1.检查是否有旧版本的jdk

 java -version

java version "1.4.2"

gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-48)

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.
[root@localhost soft]# rpm -qa|grep gcj

libgcj-4.1.2-48.el5

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

libgcj-4.1.2-48.el5

2.卸载旧的jdk

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

[root@localhost soft]# java -version

-bash: /usr/bin/java: 没有那个文件或目录

3.后安装新的jdk

./ jdk-1_5_0_15-linux-i586.bin

mkdir /usr/java

mv jdk1.5.0_15 /usr/java/

ln -s /usr/java/jdk1.5.0_16/bin/java /usr/bin/java

ln -s /usr/java/jdk1.5.0_16/bin/javac /usr/bin/javac

 

4.编写环境变量:

操作如下

#vi /etc/profile 
JAVA_HOME=/usr/java/jdk1.5.0_16 
JRE_HOME=/usr/java/jdk1.5.0_16/jre 
PATH=$PATH:$JAVA_HOME/bin:JRE_HOME/bin 
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:
export JAVA_HOME JRE_HOME PATH CLASSPATH 

5.使环境变量生效:

#source /etc/profile

你可能感兴趣的:(redhat)