下载自解压包:jdk-1_5_0_04-linux-i586.bin
#sh jdk-1_5_0_04-linux-i586.bin 按提示选择yes.
或者
#chmod 755 jdk-1_5_0_04-linux-i586.bin
#./jdk-1_5_0_04-linux-i586.bin 解压后
#mv jdk1.5.0_04 /usr/local/
到此JDK已经安装完成
2..删除原有的JDK
首先运行;
# alternatives –remove java /usr/share/java/libgcj-java-placeholder.sh
# alternatives --remove javac /usr/share/java/libgcj-javac-placeholder.sh
# alternatives --remove jar /usr/bin/fastjar
# alternatives --remove jar.1.gz /usr/share/man/man1/fastjar.1.gz
3..删去原有链接
到/usr/bin目录下,把原用的java,javac文件删除:
#rm -rf java
#rm –rf javac
在/usr/bin 下建立 软连接 java
ln -s jdk1.5.0_06/bin/java /usr/bin/java
ln -s jdk1.5.0_06/bin/javac /usr/bin/javac
为了方便后面的工作建立两个软链接:
#cd /usr/local/
#ln -s jdk1.5.0_06 /usr/local/jdk
#ln -s jdk1.5.0_06/jre/ /usr/local/jre
4.编写环境变量:
在/etc/profile里写入如下:
#vi /etc/profile
#Set Environment by NetSeek (2005/9/5)
JAVA_HOME=/usr/local/jdk
JRE_HOME=/usr/local/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
#java -version
java version "1.5.0_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
Java HotSpot(TM) Client VM (build 1.5.0_04-b05, mixed mode, sharing
6.测试JDK:
[root@www ~]# vi hello.java
public class hello {
public static void
main(String args [ ])
{ System.out.println("Hello World!");
System.out.println("看到这些代表安装成功啦!");
System.out.println("2005/9/5");
}
}
[root@www ~]# javac hello.java
[root@www ~]# java hello
Hello World!
看到这些代表安装成功啦!