查看版本
# 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.
环境
Redhat5.5 x86_64
更新JDK版本:jdk-6u30-linux-x64.bin
1.拷贝jdk-6u30-linux-x64.bin到/tmp
2.赋予可执行权限
chmod a+x jdk-6u30-linux-x64.bin
3.执行
./jdk-6u30-linux-x64.bin
4.创建/usr/java目录
mkdir/usr/java
5.把/tmp/jdk1.6.0_30目录移动至/usr/java
mv /tmp/jdk1.6.0_30/usr/java
6.删除/usr/bin/java/usr/bin/javac
rm /usr/bin/java
rm /usr/bin/javac
7.执行
ln -s /usr/java/jdk1.6.0_30/bin/java/usr/bin/java
ln -s /usr/java/jdk1.6.0_30/bin/javac/usr/bin/javac
8.编译/etc/profile,在文件末尾加上
JAVA_HOME=/usr/java/jdk1.6.0_30
JRE_HOME=/usr/java/jdk1.6.0_30/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 PATHCLASSPATH
9.执行source /etc/profile
10. 查看版本
# java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
11. 编写helloWorld程序测试
# cat test.java
public class test{
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
#javac test.java
#java test
Hello World!