Install JDK 7 on Ubuntu

from

http://www.shinephp.com/install-jdk-7-on-ubuntu/


Task: Install JDK 7 on Ubuntu desktop.
Problem 1: Java version 7 is not available from Ubuntu repositories for your Ubuntu version (prior to 11.10 Oneiric). You don’t see it neither via "Ubuntu Software Center" nor via "Synaptic Package Manager".
What to do: Download JDK 7 binaries from the official Java site.
Problem 2: You are Debian/Ubuntu user and don’t see applicable .deb package.
What to do: Again, download JDK 7 binaries from the official Java site, install and configure it manually.
Step by step instructions to install and manual configure JDK 7 on the Ubuntu 10.04 LTS (the Lucid Lynx) desktop follow:
- For my X64 Ubuntu 10.04 LTS Desktop installation I downloaded Linux x64 – Compressed Binary file named jdk-7-linux-x64.tar.gz.
- Unpack it with command
gzip -d jdk-7-linux-x64.tar.gz
You will get jdk-7-linux-x64.tar file.
- Extract files from tar archive with command
tar -xvf jdk-7-linux-x64.tar
JDK 7 package is extracted into ./jdk1.7.0 directory.
- Move JDK 7 directory to place where it should be. Right, to the /usr/lib/jvm/jdk1.7.0 directory. Use this command for that
sudo mv ./jdk1.7.0/ /usr/lib/jvm/jdk1.7.0
- Execute this command
sudo update-alternatives --config java
to know under what number you will config you new Java installation. You will get output as:

$sudo update-alternatives –config java
There are 2 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode

Press enter to keep the current choice[*], or type selection number:

Remember the last number and press enter to exit this utility.
- Execute this command
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java 3
to add your new JDK 7 installation into alternatives list. I put 3 there as 2 was last number for my configuration. You should use your own number from the previous step increased by 1.
- Execute this command
sudo update-alternatives --config java.
You will see output similar one below:

$sudo update-alternatives –config java
There are 3 choices for the alternative java (providing /usr/bin/java).

Selection Path Priority Status
————————————————————
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
3 /usr/lib/jvm/jdk1.7.0/jre/bin/java 3 manual mode

Press enter to keep the current choice[*], or type selection number: 3
update-alternatives: using /usr/lib/jvm/jdk1.7.0/jre/bin/java to provide /usr/bin/java (java) in manual mode.

In case you have other answer from update-alternatives --config java command, e.g. ‘no alternatives for java’, try this command:

sudo update-alternatives –install /usr/bin/java java /usr/lib/jvm/jdk1.7.0/jre/bin/java 0

This will select needed java version in case you had not any previous java version installed before.

The job is done. Task is completed and work is finished. Just check version of your new JDK 7 installation typing this command java -version. You should see something like this:

~$ java -version
java version “1.7.0″
Java(TM) SE Runtime Environment (build 1.7.0-b147)
Java HotSpot(TM) 64-Bit Server VM (build 21.0-b17, mixed mode)

Please be aware that we changed alias just for one java binary only – “java” itself. There are a lot of others in Java package, e.g. “javac” compiler, etc. If you try to check javac version with “javac -version” command the most probably you will get that it still has 1.6 version, e.g. on my box:

~$ javac -version
javac 1.6.0_26

To update it, make the same as you did for java runtime environment:
sudo update-alternatives –config javac // Check the java compilers you have
sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0/bin/javac [-number]
Pay attention on the change of file location at the end of command. It is needed as there’s NO “javac” in the directory
“/usr/lib/jvm/jdk1.7.0/jre/bin/”
we used for JRE configuration in previous command.
Apply this technique for other Java binaries you use.

Thanks to Nikolavp’s blog for the hints about manual JDK 7 installation and configuration.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值