Ubuntu安装JDK7

1. Download the following file:
http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-i586.tar.gz (32-bit)
http://download.oracle.com/otn-pub/java/jdk/7u1-b08/jdk-7u1-linux-x64.tar.gz (64-bit)

2. Decompress the .tar.gz file.

3. Move the JDK files to /usr/lib/jvm/jdk1.7.0 or elsewhere you like.

4. $sudo gvim /etc/environment  

You will see

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"

Change the file as (change the installation path if needed)

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0/bin"  
CLASSPATH=.:/usr/lib/jvm/jdk1.7.0/lib  
JAVA_HOME=/usr/lib/jvm/jdk1.7.0  

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/jvm/jdk1.7.0/bin"
CLASSPATH=.:/usr/lib/jvm/jdk1.7.0/lib
JAVA_HOME=/usr/lib/jvm/jdk1.7.0

And then reload .bashrc file:

source ~/.bashrc


5. Run the following commands: 

$sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/bin/java 300
$sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac 300
$sudo update-alternatives --install /usr/bin/javap javap /usr/lib/jvm/jdk1.7.0/bin/javap 300
$sudo update-alternatives --install /usr/bin/javadoc javadoc /usr/lib/jvm/jdk1.7.0/bin/javadoc 300

Installation has now done. Run $java -version for a test.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值