Linux下安装JDK 1.6(解压缩方式)

由于服务器是共用的,不给root权限,所以只能用解压缩,安装到自己home的方式来安装jdk。

1、下载最新JDK

#下载
wget http://cds-esd.sun.com/ESD6/JSCDL/jdk/6u24-b07/jdk-6u24-linux-x64.bin?AuthParam=1303266937_f832ac172b27d2af47ebec23c9a3fae1&TicketId=nod2BlEYQ3d%2BnusqlEOZWZiZcg%3D%3D&GroupName=CDS&FilePath=/ESD6/JSCDL/jdk/6u24-b07/jdk-6u24-linux-x64.bin&File=jdk-6u24-linux-x64.bin

#解压缩
chmod a+x ./jdk-6u24-linux-x64.bin
./jdk-6u24-linux-x64.bin

2、设置环境变量
编辑~/.bashrc

vim ~/.bashrc
#添加如下内容
export JAVA_HOME=/home/lhy/jdk/jdk1.6.0_24
export JAVA_BIN=/home/lhy/jdk/jdk1.6.0_24/bin
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH

3、重新登录
测试一下:

java -v
#结果
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) 64-Bit Server VM (build 19.1-b02, mixed mode)

搞定。

Leave a Reply

Your email address will not be published. Required fields are marked *