当前位置: 首页 > 工具软件 > Lucid Desktop > 使用案例 >

Install JDK 7 on Ubuntu desktop.

司空思聪
2023-12-01

Task: InstallJDK 7 on Ubuntu desktop.
Problem 1: Java version 7 is not available from Ubunturepositories for your Ubuntu version (prior to 11.10 Oneiric). You don’t see itneither via "UbuntuSoftware Center" nor via "Synaptic Package Manager".
What to do: Download JDK 7 binaries from the officialJava site.
Problem 2: You are Debian/Ubuntu user and don’t seeapplicable .deb package.
What to do: Again, download JDK 7 binaries from the officialJava site, install and configure it manually.
Step by step instructions to install and manualconfigure JDK 7 on the Ubuntu 10.04 LTS (the Lucid Lynx) desktop follow:
- For my X64 Ubuntu 10.04 LTS Desktopinstallation 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 -xvfjdk-7-linux-x64.tar
JDK 7 package is extracted into ./jdk1.7.0 directory.
- Move JDK 7 directory to place where it shouldbe. 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 younew 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 PathPriority 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 keepthe current choice[*], or type selection number:

Remember the lastnumber 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 2was last number for my configuration. You should use your own number from theprevious step increased by 1.
- Execute this command
sudo update-alternatives --config java.
You will see output similar one below:

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

Selection PathPriority 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 keepthe 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 haveother answer from update-alternatives--config java command, e.g.‘no alternatives for java’, try this command:

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

This will selectneeded java version in case you had not any previous java version installedbefore.

The job is done.Task is completed and work is finished. Just check version of your new JDK 7installation typing this command java-version. You should seesomething 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 awarethat we changed alias just for one java binary only – “java” itself. There area lot of others in Java package, e.g. “javac” compiler, etc. If you try tocheck javac version with “javac -version” command the most probably you willget that it still has 1.6 version, e.g. on my box:

~$ javac -version
javac 1.6.0_26

To update it, makethe 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 isneeded 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 forthe hints about manual JDK 7 installation and configuration.

 

 类似资料:

相关阅读

相关文章

相关问答