首页 > 代码库 > Ubuntu下安装Java环境

Ubuntu下安装Java环境

http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

2 以root用户登录将下载的jdk-8u92-linux-x64.tar.gz文件放到/temp目录下,使用如下命令解压

tar zxvf jdk-8u92-linux-x64.tar.gz

3 将解压后的jdk1.8.0_92复制到/opt下,命令如下:

root@test:~# mkdir /temp
root@test:~# cd /temp
root@test:/temp# tar zxvf jdk-8u92-linux-x64.tar.gz 
root@test:/temp# cd /opt
root@test:/opt# mv /temp/jdk1.8.0_92/ .
root@test:/opt# ls -l
总用量 4
drwxr-xr-x 8 uucp 143 4096 4月 1 12:20 jdk1.8.0_92

4 在/bin目录下创建java软链接

root@test:/opt# cd /bin
root@test:/bin# ln -s /opt/jdk1.8.0_92/bin/java java

   验证软件接的正确性

root@test:/bin# java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

5 设置Java环境

root@test:/bin# gedit /etc/profile
export JAVA_HOME=/opt/jdk1.8.0_92
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH={JAVA_HOME}/bin:$PATH
root@test:/bin# source /etc/profile
root@test:/bin# echo $JAVA_HOME
/opt/java1.8.0_92

6 切换到其它用户验证

ccskun@test:~$ echo $JAVA_HOME
/opt/jdk1.8.0_92
ccskun@test:~$ java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)

Ubuntu下安装Java环境