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

link|improve this question
2  
Here's a quick tutorial for installing JDK7 on Ubuntu. – blackcompe Nov 4 '11 at 18:08
I have it in this post forum.xda-developers.com/… – user106720 Nov 24 '11 at 17:24
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
feedback

migrated from stackoverflow.com Nov 4 '11 at 16:01

This question came from our site for professional and enthusiast programmers.

5 Answers

up vote 61 down vote accepted

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 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 add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

[Source]

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-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: 2

Select (2) and press enter

Now running:

java -version

Returns:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)
link|improve this answer
@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 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 at 6: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 at 17:46
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 2 days ago
show 2 more comments
feedback

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

link|improve this answer
feedback

I'd suggest to go with openjdk if possible (for any average user that is). The only thing you might need from sun/oracle is browser plugin, but that could be installed without installing the jre (just unpack).

link|improve this answer
feedback

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

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

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

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 ;)

link|improve this answer
Cool solution, thanks: worked perfectly for me! – ngeek Apr 24 at 13:07
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 yesterday
You might want to file a bug report github.com/flexiondotorg/oab-java6/issues – Paweł Prażak 10 hours ago
feedback

Upon attempting
$ sudo add-apt-repository ppa:ferramroberto/java
My terminal would hang, not respond to ^C and ultimately (5 min or so) return

Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 88, in <module>
    ppa_info = get_ppa_info_from_lp(user, ppa_name)
  File "/usr/lib/python2.7/dist-packages/softwareproperties/ppa.py", line 80, in         get_ppa_info_from_lp
curl.perform()
pycurl.error: (28, 'connect() timed out!')

I resolved this by becoming root, exporting the http/https proxies and then repeating the above line without sudo.

link|improve this answer
feedback

protected by Community Mar 6 at 23:15

This question is protected to prevent "thanks!", "me too!", or spam answers by new users. To answer it, you must have earned at least 10 reputation on this site.

Not the answer you're looking for? Browse other questions tagged or ask your own question.