100

Since 11.10 Ubuntu does not provide the sun-java-jdk, how do I install it?

fixer1234
  • 27,064
  • 61
  • 75
  • 116
Rodja
  • 1,167
  • 4
  • 10
  • 9
  • One other problem with openJDK (at least coupled with Nvidia cards) is when using Java2D, transparency is extremely slow, while with Sun it is blazing fast. – vextorspace Dec 16 '11 at 14:26
  • I have it in this post http://forum.xda-developers.com/showpost.php?p=19446284&postcount=62 –  Nov 24 '11 at 17:24
  • 3
    [Here's](http://strug.wordpress.com/2009/02/22/installing-java-7-snapshot-on-ubuntu/) a quick tutorial for installing JDK7 on Ubuntu. – blackcompe Nov 04 '11 at 18:08

3 Answers3

105

NOTE: Some of the contents of this answer might have become obsolete and there are some comments where people have reported problems. You're advised to read through the comments first.

--

Ubuntu 11.10 Oneric

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

[Source]

Ubuntu 12.04 Precise

Clean up the historical open jdk:

sudo apt-get purge openjdk*

Add a new repo and install the sdk:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:eugenesan/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

If you want the JRE and the browser plugin:

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

[Source]

Ubuntu 12.04 (Precise Pangolin) - another way

Thanks to the comments, please note that you can try this method too: http://www.liberiangeek.net/2012/04/install-oracle-java-jdk-7-in-ubuntu-12-04-precise-pangolin/

Make the sun java the default

You may want to also add the following

sudo update-alternatives --config java

You should get the following

Selection Path Priority Status

0 /usr/lib/jvm/java-7-oracle/bin/java 1 auto mode 1 /usr/lib/jvm/java-7-oracle/bin/java 1 manual mode * 2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1 manual mode

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

Select (2) and press enter

Now running:

java -version

Returns:

java version "1.7.0_04" Java(TM) SE Runtime Environment (build 1.7.0_04-b20) Java HotSpot(TM) Server VM (build 23.0-b21, mixed mode)

IsaacS
  • 121
  • 1
  • 11
JMax
  • 3,195
  • 1
  • 22
  • 19
  • @Renaud I've approved the edit, in case somebody runs into the same issues. – slhck Nov 22 '11 at 10:45
  • Is there any up to date repo? – Paweł Prażak Apr 22 '12 at 18:12
  • @PawełPrażak: there is no point in downvoting when you didn't find what you expected... yet, I've edited the answer with a *seeminlgy* working solution for Ubundu 12.04. I cannot test it right here, please tell us if it works or edit the post with a wokring solution. – JMax Apr 23 '12 at 06:39
  • @JMax sorry, but I'm not sure what do you mean, the thing is that this repo contains 1.6.0_26 - it's outdated and have lots of unfixed security issues. But anyway I\ve found a almost perfect solution, see below :) – Paweł Prażak Apr 25 '12 at 17:46
  • 9
    I get a bad error with these instructions for 12.04: sha256sum mismatch jdk-7u3-linux-x64.tar.gz Oracle JDK 7 is NOT installed. – Jay Taylor May 28 '12 at 05:46
  • @JayTaylor: are you sure your download worked properly? did you try it all over again? This kind of error is more likely a partial or incorrect download – JMax May 28 '12 at 19:01
  • 2
    This failed for me as well. Same error. Nightmare. – Whit May 29 '12 at 19:13
  • @JayTaylor do not use ppa:eugenesan/java, it's broken. ppa:webupd8team/java works fine. – Liz Av Jun 13 '12 at 01:39
  • on 11.10 sudo apt-get update returns this `W: GPG error: http://ppa.launchpad.net oneiric Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 2EA8F35793D8809A W: Failed to fetch http://ppa.launchpad.net/sun-java-community-team/sun-java6/ubuntu/dists/oneiric/main/source/Sources 404 Not Found W: Failed to fetch http://ppa.launchpad.net/sun-java-community-team/sun-java6/ubuntu/dists/oneiric/main/binary-amd64/Packages 404 Not Found` – SSH This Jun 14 '12 at 00:50
  • 1
    To install on 12.04, this was the only way I could do it: http://www.liberiangeek.net/2012/04/install-oracle-java-jdk-7-in-ubuntu-12-04-precise-pangolin/ – Steve HHH Jun 15 '12 at 05:02
  • This is terrible I wish I had read the comments, I wish I could downvote... please fix this. :( – z7sg Ѫ Jun 20 '12 at 21:42
  • 1
    @z7sgѪ: please note that instead of complaining you can edit the answer, it will be peer reviewed and if relevand approved. This way, this (very old) answer will remain up-to-date. – JMax Jun 21 '12 at 05:16
  • 2
    I needed to install oracle jdk 1.6 on lubuntu 12.04 and none of the provided PPA's worked. Didn't want to mess with binary installers so i just used `add-apt-repository ppa:eugenesan/java` and then replaced 'precise' with 'oneiric' in synaptic. So now I have 1.6.0_26 on precise - not the latest but enough for me. – ccpizza Jul 07 '12 at 17:52
  • The 12.04 way also works on 12.10 – Vlad Preda Apr 13 '13 at 21:20
  • Looks like eugenesan/java is some really-really nasty ppa. First of all it is broken. Even if I remove it from Software Center, it does not go away! I tried to purge it as well, still no luck. Had to reinstall the OS. – Bhushan Sep 07 '13 at 22:52
  • @JMax please remove this answer, as other people says its toxic! – Tommaso Barbugli Oct 02 '13 at 06:24
  • 1
    @TommasoBarbugli: I've changed my answer to a community wiki. Feel free to edit and complete it if you think this is necessary – JMax Oct 03 '13 at 14:47
  • For those who corrupted your system, this link might be of your help http://askubuntu.com/a/126419/24203 – IsaacS Oct 16 '13 at 02:16
13

There is very good page on official Ubuntu wiki. There you can find all recommended methods. I've used this excellent automatic script.

Make sure git is installed:

sudo apt-get install git

Sun/Oracle Java 1.6.0

Build local debs:

wget https://raw.github.com/flexiondotorg/oab-java6/master/oab-java.sh
chmod +x oab-java.sh
sudo ./oab-java.sh

Script will build packages from source and place them in local repo, then they can be installed e.g.:

sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-fonts sun-java6-source

You can see all available packages in /var/local/oab/deb

Remember to select the right version:

sudo update-alternatives --config java

To setup everything else (like browser plugin, keytool, etc.) you can use this (it will be a long list!):

sudo update-alternatives --all

The script is a wrapper for this Debian script, if you're curious ;)

Oracle Java 1.7.0_51

There is an Issue 123 currently in OAB and a pull request

Here is the patched vesion:

wget https://raw.github.com/ladios/oab-java6/master/oab-java.sh
chmod +x oab-java.sh
sudo ./oab-java.sh -7

sudo apt-get update
sudo sudo apt-get install oracle-java7-jdk oracle-java7-fonts oracle-java7-source 

Read more on AskUbuntu

Paweł Prażak
  • 277
  • 2
  • 10
  • 1
    Nothing.[x] Installing Java build requirements failed [i] Showing the last 5 lines from the logfile (/home/me/oab-java6.sh.log)... Errors were encountered while processing: oracle-java7-installer E: Sub-process /usr/bin/dpkg returned an error code (1) 3135's retcode: 100 failed – Whit May 29 '12 at 19:16
  • You might want to file a bug report https://github.com/flexiondotorg/oab-java6/issues – Paweł Prażak May 30 '12 at 18:20
  • 1
    `wget https://raw.github.com/flexiondotorg/oab-java6/master/oab-java6.sh` says ERROR 404: Not Found. – SSH This Jun 14 '12 at 00:53
  • 1
    Works for me, check: https://github.com/flexiondotorg/oab-java6/blob/master/oab-java.sh – Paweł Prażak Jun 14 '12 at 09:05
4

You can install the official package from Oracle :

http://www.oracle.com/technetwork/java/javase/downloads/jdk-7u1-download-513651.html

choose linux as your platform

Peter Szanto
  • 171
  • 7
  • Supplemental instructions for 12.04 available here: http://www.liberiangeek.net/2012/04/install-oracle-java-jdk-7-in-ubuntu-12-04-precise-pangolin/ – Steve HHH Jun 15 '12 at 05:02