Red Hat Enterprise Linux 4服务器上安装jdk1.6

1:下载JDK6.0

地址:http://java.sun.com/javase/downloads/index.jsp
我下载的是jdk-6u11-linux-i586.bin

2:用cd命令转到放jdk文件的目录下释放压缩包jdk1.6.0_11,

3:用命令:sh jdk-6u11-linux-i586.bin ,一直按回车,直到出现

    Do you agree to the above license terms? [yes or no] 输入:yes


4.完成释放,运行ls 会发现当前目录下生成一个文件夹:jdk1.6.0_011


5.更改名字,执行命令: mv ./jdk1.6.0_11 ./jdk6.0. 再执行ls,发现名字已经改为jdk6.0.(这一步不做也可以,改名字主要是为了方便)


6. 更改字符集为utf-8:


[root@qudee jdk6.0]# export LANG=en_US


[root@qudee jdk6.0]# export LC_ALL=en_US


7.执行命令: ./bin/java –version 发现已经成功,


java version "1.6.0_11"


Java(TM) SE Runtime Environment (build 1.6.0_11-b05)


Java HotSpot(TM) Server VM (build 1.6.0_011-b05, mixed mode)


再执行java –version


java version "1.4.2"


gcj (GCC) 3.4.6 20060404 (Red Hat 3.4.6-3)


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.


出错了,原因是环境变量没设置好.


8.设置环境变量,执行命令vi /etc/profile


出现编辑框,在


HOSTNAME=`/bin/hostname`


HISTSIZE=1000


底下添加环境变量的路径:


JAVA_HOME=/opt/java/jdk6.0


CLASS_PATH=$JAVA_HOME/lib:JAVA_HOME/jre/lib:JAVA_HOME/lib/tools.jar:$CLASS_PATH


PATH=$JAVA_HOME/bin:$PATH


export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC 在此行后面添加

export  CLASS_PATH JAVA_HOME


OK! 按Esc 推出编辑框,再按Shift+;,输入wq (写入 保存并推出)


重新启动系统。


9.检查是否安装成功,输入命令: java –version


出现信息:


java version "1.6.0_02"


Java(TM) SE Runtime Environment (build 1.6.0_02-b05)


Java HotSpot(TM) Server VM (build 1.6.0_02-b05, mixed mode)


说明安装成功!

posted @ 2008-12-09 12:27  不染丹心  阅读(1175)  评论(0编辑  收藏  举报