ubuntu 下安装jdk

1.下载jdk:www.oracle.com/technetwork/java/javase/downloads/index.html

2.解压jdk:# tar -zxvf jdk-7u60-linux-x64.tar.gz,得到

3.打开/etc/profile文件添加变量如下:

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))  

# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).  

#set java environment  

  

export JAVA_HOME=/usr/local/java/jdk1.7.0_60 
 
export JRE_HOME=/usr/local/java/jdk1.7.0_60/jre  
 
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH  
 
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$JAVA_HOME:$PATH

一般更改/etc/profile文件后,需要重启机器才能生效。这里介绍一种不用重启使其生效的方法

# source /etc/profile

4.查看java环境变量是否配置成功

root@ubuntu:/usr/local/java/jdk1.7.0_60# java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

备注:1.新装ubuntu切换到root:sudo passwd root

   2./usr:应用程序存放目录

你可能感兴趣的:(ubuntu)