Install Oracle Java 7 in Ubuntu via PPA Repository

10:45 PM

We've previously written about installing Oracle JDK 7 in Ubuntu using a script with a GUI provided by Zenity. Some may find this method hard to use and also, it comes with GTK dependencies. So as an alternative that doesn't have any GTK dependencies and comes with automatic updates too, I've set up an Ubuntu PPA for the latest Oracle Java 7 (JDK).

If you really need to use Oracle (ex Sun) Java instead of OpenJDK in Ubuntu, here's an easy way to do it: a PPA repository to install and keep your computer up to date with the latest Oracle Java 7 (JDK).

Oracle JDK7 itself is not hosted in the PPA because that's not allowed by the new Java license (which is also the reason why it has been removed from the official Ubuntu repositories); the package in the PPA automatically downloads (and installs) Oracle Java JDK 7 from its official website and installs it on your computer, just like the flashplugin-installer package does.


Please note that this package is currently in alpha and is offered without any guarantees, so it may or may not work! Use it at your own risk! The package should support proxies just like the flashplugin-installer does, but it may fail if your ISP or router blocks some non-standard ports because Oracle uses quite a few redirects for the Java 7 binary download links. If the download fails because of blocked ports or because you're behind a firewall, use the manual Oracle Java 7 installation method (link in the beginning of the post).


Install Oracle Java 7 in Ubuntu via PPA


This package provides Oracle Java JDK 7 (which includes Java JDK, JRE and the Java browser plugin). However, you can't only install Oracle JRE - the PPA only provides the full Oracle JDK7 package.


To add our PPA and install the latest Oracle Java 7 in Ubuntu (supports Ubuntu 12.04, 11.10, 11.04 and 10.04), use the commands below:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer


Removing Oracle Java 7


If you don't want to use Oracle Java (JDK) 7 anymore and want to go back to OpenJDK, all you have to do is remove the Oracle JDK7 Installer and the previous Java (OpenJDK, etc.) version will be used:
sudo apt-get remove oracle-java7-installer


The package is based on Bruce Ingalls' Java Update script and on the flashplugin-installer debian package - thanks!

0 comments

» read more....

How To Install Oracle Java 7 (JDK) In Ubuntu

9:43 PM

As you probably know, Oracle Java (JVM/JDK) will not be available in the Debian / Ubuntu repositories anymore because Oracle retired the "Operating System Distributor License for Java" (JDL) and the only release available in the repositories will be OpenJDK.

But of course, Oracle Java can still be downloaded from its website if you really need it and don't want to use OpenJDK:

Linux users who prefer to use the thoroughly tested Oracle JDK 6 or Oracle JDK 7 binaries over OpenJDK builds packaged in their Linux distributions of choice can of course as usual simply get the gratis download at http://oracle.com/java under the same terms as users on other platforms.

- more info @ robilad

However, installing it in Ubuntu is not that easy, so here is how to install the latest Sun Oracle Java JDK 7 (at the time I'm writing this post) in Ubuntu.


Install Oracle Java JDK 7 in Ubuntu


Update: Oracle JDK 7 is now available in a PPA for Ubuntu users (the files are not distributed in the PPA, instead, the .deb automatically downloads and installs Oracle JDK). If you prefer the PPA way (which also provides automatic updates) instead of manually installing it, see: Install Oracle Java 7 in Ubuntu via PPA Repository

Warning: JDK 7 is available as a developer preview release, so use it at your own risk.


For the installation we'll be using an old script created by WebUpd8 reader Bruce Ingalls which I've updated to work with the latest Oracle JDK 7 (just a minor modification). The installation instructions below only work for Oracle JDK.

Let's begin!


1. Download the latest Oracle JDK 7 from HERE (you must click "accept license" and then download the .tar.gz package for your computer architecture - jdk-7-linux-i586.tar.gz or jdk-7-linux-x64.tar.gz; these filenames are just examples, they will change on future releases). You can use these instructions for older JDK versions too, but make sure you use the appropriate folder names, etc.


2. Extract the downloaded Oracle Java JDK archive in your home folder and rename the newly created folder to "java-7-oracle" - we must move this folder to /usr/lib/jvm using the following commands:
cd
sudo mkdir -p /usr/lib/jvm/ #just in case
sudo mv java-7-oracle/ /usr/lib/jvm/

3. Install Update Java package created by Bruce Ingalls (packages available for Ubuntu 11.10, 11.04, 10.10 and 10.04):
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install update-java

If you don't want to add the WebUpd8 PPA, you can also manually download the script. The script may work with other Linux distributions, but it has only been tested on Ubuntu.


4. Now run the following command in a terminal to install Oracle Java JDK:
sudo update-java

The script will ask you to select the Java version - select "java-7-oracle" for Oracle Java JDK 7, click OK and wait for it to finish:

Java Updater



After a few minutes, Oracle Java JDK should be successfully installed on your Ubuntu machine. You can check out the version by running these commands in a terminal:
java -version
javac -version

The version should be "1.7.0".



Install Oracle Java 7 Browser plugin



The Java browser plugin should be installed automatically. But in case it doesn't show up in your browser, here's what to do.


Even though the steps below are for Firefox, the plugin will also be updated in Chrome (possibly other browsers too) as it looks under ~/.mozilla/plugins folder for plugins too.

Firstly, remove old Java plugin links using the commands below:
rm -f ~/.mozilla/plugins/libnpjp2.so ~/.mozilla/plugins/libjavaplugin_oji.so
sudo rm -f /usr/lib/firefox/plugins/libnpjp2.so /usr/lib/firefox/plugins/libjavaplugin_oji.so


And for the last step, let's create a simbolic link for the newly installed Java into the Mozilla plugins directory:

- 32bit:
mkdir -p ~/.mozilla/plugins
ln -s /usr/lib/jvm/java-7-oracle/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/

- 64bit:
mkdir -p ~/.mozilla/plugins
ln -s /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/




Reverting the changes


Update 15 December, 2011: Sun Java is no longer available in the older Ubuntu repositories either so the only alternative is to install OpenJDK instead:
sudo apt-get install openjdk-6-jdk icedtea-plugin


Now run our script:
sudo update-java

And select the "java-6-sun-1.6.0.26" ("java-6-sun" works too) for Oracle JDK or the "java-1.6.0-openjdk" folder for OpenJDK.


Let's revert the browser plugin changes too:
rm -f ~/.mozilla/plugins/libnpjp2.so

32bit:
sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/

64bit:
sudo ln -s /usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

0 comments

» read more....