
The newest versions of the JDK and JRE are no longer in the official repositories and require a manual installation to get them to work. This guide demonstrates the steps required in order to install the JDK and JRE, version 7, on an Ubuntu or Ubuntu based system.
This guide is not to be confused with OpenJDK, a 100% open-source implementation of the Java language. The JDK offered by Oracle has a few binaries which could not be released under an open-source license and is required for the development of many Java applications.
Part I: Downloading and installing the JDK
- Go to the Official Download Page and download either the 32 or 64 bit tar.gz file of the JDK and save to the home directory.
- Uncompress the file by typing in the following command into the terminal (CTRL+ALT+T):
tar -xvf jdk-7*
(The command will uncompress any file that begins with jdk-7) - Create a directory in
/usr/libsudo mkdir /usr/lib/jvm
- Move the JDK to the proper directory
sudo mv ./jdk1.7* /usr/lib/jvm/jdk1.7.0
Part II: Activating the newly installed JDK
- Update the paths to Java
update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.7.0/bin/java" 1 sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.7.0/bin/javac" 1 sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.7.0/bin/javaws" 1
- Update the path priorities
sudo update-alternatives --config java
The output should look similar to that below. Choose the one withjdk-1.7.0in the path. In this example, it would be 3.$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. - Check the version of the newly installed JDK.
java -version
java version “1.7.0” Java(TM) SE Runtime Environment (build 1.7.0-b147) Java HotSpot(TM) Client VM (build 21.0-b17, mixed mode)
- Repeat above for:
sudo update-alternatives --config javac sudo update-alternatives --config javaws
Congratulations, the JDK and JRE should now both be working as intended (hopefully). To get Java applications to run inside the web browser, there is a plugin called icedtea that should do the trick. A tutorial for that is available at Ask Ubuntu (near the bottom).
No comments:
Post a Comment