Jdk安装:
[root@b home]# ls
jdk-1_5_0_12-linux-i586-rpm.bin lost+found oracle
1、将jdk进行解压
[root@b home]# ./jdk-1_5_0_12-linux-i586-rpm.bin
2、将解压文件copy到/usr/java下
[root@b home]# cp jdk-1_5_0_12-linux-i586.rpm /usr/java
[root@b home]# cd /usr/java
3、进行安装
[root@b java]# rpm -ivh jdk-1_5_0_12-linux-i586.rpm
Preparing... (########################################### [100%]
package jdk-1.5.0_12-fcs is already installed
4、将环境变量加入到profile中,如果写入到(/etc/profile)对所有用户都生效,如果只对某个用户生效写入到(/home/username/profile)中
export JAVA_HOME = /usr/java/jdk1.5
export PATH = $PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
exportCLASSPATH=.:/usr/java/jdk1.5/lib:/usr/java/jdk1.5/jre/lib:$CLASSPATH
5、验证安装结果
[root@b java]# java -version
-bash: java: command not found
错误原因是环境变量未生效。
[root@b java]# source /etc/profile
[root@b java]# java -version
java version "1.5.0_12"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_12-b04)
Java HotSpot(TM) Client VM (build 1.5.0_12-b04, mixed mode, sharing)
至此安装成功。
jdk下载地址:http://java.sun.com/javase/downloads/index_jdk5.jsp