[Tutorial] Install Sun Java JDK 6 on Ubuntu 12.04 LTS

Search This thread

Peteragent5

Senior Member
Jan 1, 2012
1,280
2,025
Richmond
java_android.jpg


Installing Java JDK 6

Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk

For good measure we can also install the oracle-java7-jdk using the apt-repository provide by www.webupd8.org

Code:
sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main"
sudo apt-get update 
sudo apt-get install sun-java5-jdk sun-java6-jdk oracle-java7-installer

Test Java: [highlight]java -version[/highlight]

Credits to:
Google
Android Source
trevd
 
Last edited:

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4
Thx but it dosent work T^T

I Think this was covered back in may with this [GUIDE] Simple Java6 installation on Precise/Mint-Maya/Ubuntu 12.04 LTS

Nothing against the OP, Credits for attempting the spread the knowledge but that ubuntu help page is just plain doing it wrong when it comes to oracle! :laugh: Unfortunately the entire internet ( yes, I searched it all :p ) seems to use it as a reference so there's well over 9000 guides that seem to use that script retrieval method. It's simply not required

Just use the google way and pull both jdk-5 and jdk-6 from ubuntu's own archived apt-repos, it's never let me down yet! For good measure we can also install the oracle-java7-jdk using the apt-repository provide by www.webupd8.org

Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main"
sudo apt-get update 
sudo apt-get install sun-java5-jdk sun-java6-jdk oracle-java7-installer

all the java under the sun ( microsystems ) and 1 under oracle :D
 
Last edited:

jonah1234

Senior Member
May 29, 2012
1,762
1,089
I'm getting this error when trying to update...
Code:
[email protected]:~$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
[email protected]:~$ sudo apt-get update
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
[email protected]:~$

can anyone help please. thanks in advance.
 

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4
Looks like you've got another program thats locking the access to the sources. this normally you normally get this error if you forget to add sudo. Are you running automatic background updates or have you got a package manager open or the sources dialog?
Might be worth giving it the old "switch it on and off" again routine :D then try again

Sent from my Nexus 7 using xda premium
 
  • Like
Reactions: LaputaCake

Peteragent5

Senior Member
Jan 1, 2012
1,280
2,025
Richmond
I'm getting this error when trying to update...
Code:
[email protected]:~$ sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
[email protected]:~$ sudo apt-get update
E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
[email protected]:~$

can anyone help please. thanks in advance.

Try these commands:
Code:
sudo rm /var/lib/apt/lists/* -vf 
sudo apt-get update
 

jonah1234

Senior Member
May 29, 2012
1,762
1,089
Ok now the sudo apt-get update worked but i'm getting another error...
Code:
[email protected]:~$ sudo apt-get install sun-java6-jdkReading package lists... Done
Building dependency tree       
Reading state information... Done
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sun-java6-jdk' has no installation candidate
[email protected]:~$
 

Peteragent5

Senior Member
Jan 1, 2012
1,280
2,025
Richmond
Ok now the sudo apt-get update worked but i'm getting another error...
Code:
[email protected]:~$ sudo apt-get install sun-java6-jdkReading package lists... Done
Building dependency tree       
Reading state information... Done
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sun-java6-jdk' has no installation candidate
[email protected]:~$

Have you added the repos?
 

flowish

Retired Recognized Developer
Oct 26, 2011
374
788
i think this code doesnt work and we dont need, because this is for ubuntu hardy and lucid, not for precise pangolin.
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"


another tutorial,open terminal and type :

Code:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java6-installer




:good:
 
Last edited:

trevd

Inactive Recognized Developer
Jul 19, 2011
895
1,271
Hull
Samsung Galaxy Tab 4
i think this code doesnt work and we dont need, because this is for ubuntu hardy and lucid, not for precise pangolin.
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

:good:

Nah, Apt doesn't work like that, and using these archive repositories works on any version and any ubuntu based distro, well anywhere you've got apt installed really. although some distro don't come with add-apt-repository which is a python helper script, in which case you can manually add following the lines to /etc/apt/sources.list.

Code:
deb http://old-releases.ubuntu.com/ubuntu hardy main multiverse
deb-src http://old-releases.ubuntu.com/ubuntu hardy main multiverse
deb http://old-releases.ubuntu.com/ubuntu hardy-updates main multiverse
deb-src http://old-releases.ubuntu.com/ubuntu hardy-updates main multiverse
deb http://archive.canonical.com/ lucid partner
deb-src http://archive.canonical.com/ lucid partner

The "version" labels are irrelevant to the installation and are used to help apt resolve the directory on the web server where the Packages list is located, hardy's multiverse one is here http://archive.ubuntu.com/ubuntu/ubuntu/dists/hardy/multiverse/binary-amd64/ for example. this is what "apt-get update" is doing

The reason for all three repository being needed is, java6 in the lucid repository has a dependency on a package found in the hardy repos, the upshot of adding all three is the option of installing java5 as well, just in case you get an urge to build any version of android that is pre gingerbread

All that being said using webupd8team ppa repository is fine. anything beats messing around with some daft installation script and an overly complicated multi-step process which seems to have been a previously banded about as the installation method.

Here's a console dump for both Ubuntu 12.04 and lubuntu 12.10. This is what you should be seeing if everything is working correctly.

Thanks
 
Last edited:

LesterBurnham

Member
Dec 15, 2012
6
3
United Kingdom
Thank you so much Peteragent5 and trevd! I spent ages banging my head against the wall with this! Now I can hopefully get on with some fun stuff instead of wasting time setting up my environment. :)
 
  • Like
Reactions: trevd

sarkar1990

Senior Member
Dec 7, 2012
945
528
New Delhi
Well, I always do it manually. In case you want to know:

Go to http://www.oracle.com/technetwork/j...ownloads-javase6-419409.html#jdk-6u45-oth-JPR anddownload the x64 bin file. You need to login to oracle for this.

Once that is done follow the steps:

Code:
chmod a+x jdk-6u45-linux-x64.bin

sudo mkdir /usr/lib/jvm

sudo mv jdk-6u45-linux-x64.bin /usr/lib/jvm/

cd /usr/lib/jvm
sudo ./jdk-6u37-linux-i586.bin

sudo update-alternatives --config java
sudo update-alternatives --config javac

java -version

This usually works. But in case you don't see your version while running

java -version

Just set path in your .bashrc
 

fish83

New member
Nov 19, 2013
1
2
change archive.ubuntu.com to old-releases.ubuntu.com

Ok now the sudo apt-get update worked but i'm getting another error...
Code:
[email protected]:~$ sudo apt-get install sun-java6-jdkReading package lists... Done
Building dependency tree       
Reading state information... Done
Package sun-java6-jdk is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'sun-java6-jdk' has no installation candidate
[email protected]:~$

Hi,
Hardy does not exist anymore into archive.ubuntu.com
replace archive.ubuntu.com by old-releases.ubuntu.com

sorry I can paste the code, i have no right at this moment
To prevent spam on the XDA forums, ALL new users prevented from posting outside links in their messages. After approximately 10 posts, you will be able to post outside links. Thank you for understanding!

fish83
 
  • Like
Reactions: JLow0214 and trevd

Top Liked Posts

  • There are no posts matching your filters.
  • 20
    java_android.jpg


    Installing Java JDK 6

    Code:
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
    sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
    sudo apt-get update
    sudo apt-get install sun-java6-jdk

    For good measure we can also install the oracle-java7-jdk using the apt-repository provide by www.webupd8.org

    Code:
    sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main"
    sudo apt-get update 
    sudo apt-get install sun-java5-jdk sun-java6-jdk oracle-java7-installer

    Test Java: [highlight]java -version[/highlight]

    Credits to:
    Google
    Android Source
    trevd
    11
    Thx but it dosent work T^T

    I Think this was covered back in may with this [GUIDE] Simple Java6 installation on Precise/Mint-Maya/Ubuntu 12.04 LTS

    Nothing against the OP, Credits for attempting the spread the knowledge but that ubuntu help page is just plain doing it wrong when it comes to oracle! :laugh: Unfortunately the entire internet ( yes, I searched it all :p ) seems to use it as a reference so there's well over 9000 guides that seem to use that script retrieval method. It's simply not required

    Just use the google way and pull both jdk-5 and jdk-6 from ubuntu's own archived apt-repos, it's never let me down yet! For good measure we can also install the oracle-java7-jdk using the apt-repository provide by www.webupd8.org

    Code:
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
    sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
    sudo add-apt-repository "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main"
    sudo apt-get update 
    sudo apt-get install sun-java5-jdk sun-java6-jdk oracle-java7-installer

    all the java under the sun ( microsystems ) and 1 under oracle :D
    4
    i think this code doesnt work and we dont need, because this is for ubuntu hardy and lucid, not for precise pangolin.
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
    sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"


    another tutorial,open terminal and type :

    Code:
    sudo add-apt-repository ppa:webupd8team/java
    sudo apt-get update
    sudo apt-get install oracle-java6-installer




    :good:
    3
    i think this code doesnt work and we dont need, because this is for ubuntu hardy and lucid, not for precise pangolin.
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy main multiverse"
    sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu hardy-updates main multiverse"
    sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"

    :good:

    Nah, Apt doesn't work like that, and using these archive repositories works on any version and any ubuntu based distro, well anywhere you've got apt installed really. although some distro don't come with add-apt-repository which is a python helper script, in which case you can manually add following the lines to /etc/apt/sources.list.

    Code:
    deb http://old-releases.ubuntu.com/ubuntu hardy main multiverse
    deb-src http://old-releases.ubuntu.com/ubuntu hardy main multiverse
    deb http://old-releases.ubuntu.com/ubuntu hardy-updates main multiverse
    deb-src http://old-releases.ubuntu.com/ubuntu hardy-updates main multiverse
    deb http://archive.canonical.com/ lucid partner
    deb-src http://archive.canonical.com/ lucid partner

    The "version" labels are irrelevant to the installation and are used to help apt resolve the directory on the web server where the Packages list is located, hardy's multiverse one is here http://archive.ubuntu.com/ubuntu/ubuntu/dists/hardy/multiverse/binary-amd64/ for example. this is what "apt-get update" is doing

    The reason for all three repository being needed is, java6 in the lucid repository has a dependency on a package found in the hardy repos, the upshot of adding all three is the option of installing java5 as well, just in case you get an urge to build any version of android that is pre gingerbread

    All that being said using webupd8team ppa repository is fine. anything beats messing around with some daft installation script and an overly complicated multi-step process which seems to have been a previously banded about as the installation method.

    Here's a console dump for both Ubuntu 12.04 and lubuntu 12.10. This is what you should be seeing if everything is working correctly.

    Thanks
    2
    change archive.ubuntu.com to old-releases.ubuntu.com

    Ok now the sudo apt-get update worked but i'm getting another error...
    Code:
    [email protected]:~$ sudo apt-get install sun-java6-jdkReading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package sun-java6-jdk is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    
    E: Package 'sun-java6-jdk' has no installation candidate
    [email protected]:~$

    Hi,
    Hardy does not exist anymore into archive.ubuntu.com
    replace archive.ubuntu.com by old-releases.ubuntu.com

    sorry I can paste the code, i have no right at this moment
    To prevent spam on the XDA forums, ALL new users prevented from posting outside links in their messages. After approximately 10 posts, you will be able to post outside links. Thank you for understanding!

    fish83