Ubuntu 12.04 – install sun jdk 6-7

java logo

Ubuntu GNU/Linux 12.04 LTS (Precise Pangolin) released. I wanted to manually install the Sun JDK 6 and 7 on Ubuntu.

Updated for Ubuntu GNU/Linux 13.04 (Raring Ringtail).

Updated for Ubuntu GNU/Linux 12.10 (Quantal Quetzal).

Installing Sun JDK 6 on Ubuntu 12.04 / 12.10 / 13.04:

  • Make the bin file executeable:
chmod +x jdk-6u32-linux-x64.bin
  • Extract the bin file:
./jdk-6u32-linux-x64.bin
  • For Ubuntu 13.04: There is no longer a jvm folder in /usr/lib, therefore create jvm folder
sudo mkdir /usr/lib/jvm
  • Move extracted folder to this location:
sudo mv jdk1.6.0_38 /usr/lib/jvm/jdk1.6.0_38
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.6.0_38/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_38/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_38/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.6.0_38/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Installing Sun JDK 7 on Ubuntu 12.04 / 12.10 / 13.04:

  • Download the sun jdk 7 tar file from here
  • Extract the tar file:
tar -xvzf jdk-7u11-linux-x64.tar.gz
  • For Ubuntu 13.04: There is no longer a jvm folder in /usr/lib, therefore create jvm folder
sudo mkdir /usr/lib/jvm
  • Move extracted folder to this location:
sudo mv jdk1.7.0_11 /usr/lib/jvm/jdk1.7.0_11
  • Install new java source in system:
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_11/bin/javac 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_11/bin/java 1
sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_11/bin/javaws 1
  • Choose default java:
sudo update-alternatives --config javac
sudo update-alternatives --config java
sudo update-alternatives --config javaws
  • java version test:
java -version
  • Verify the symlinks all point to the new java location:
ls -la /etc/alternatives/java*
  • Enable Java plugin for Mozilla Firefox (even for Chrome)
#for 64-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins
#for 32-Bit jdk
sudo ln -s /usr/lib/jvm/jdk1.7.0_11/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

Update: I have added Java Web Start configuration (Thanks Jack).

Update: I have added Java Plugin configuration for Mozilla Firefox even for Chrome (Thanks shetty).

Update: JAVA_HOME configuration: Some tools require JAVA_HOME variable. You can set JAVA_HOME in Ubuntu so simple: Edit the file .bashrc under your home directory and add the following lines: (if .bashrc is hidden, click in Nautilus Menu View > Show Hidden Files)

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11 or /usr/lib/jvm/jdk1.6.0_38
export PATH=$JAVA_HOME/bin:$PATH

or add this JAVA_HOME=/usr/lib/jvm/jdk1.7.0_11 in /etc/environment with sudo gedit /etc/environment

98 Comments

  1. Klau3
    Apr 30, 2012 @ 21:11:12

    Works if you add those two steps:
    rm -rf ~/.swt/lib/linux/x86
    ln -s /usr/lib/jni ~/.swt/lib/linux/x86

    Reply

    • Cem Ikta
      May 01, 2012 @ 01:46:19

      Hi,
      I have not .swt directory in my ubuntu 12.04 and without those commands it works!

      Reply

  2. Technology And Software » Ubuntu 12.04 – install sun jdk 6-7
    May 02, 2012 @ 17:35:06

    Reply

  3. Dor
    May 06, 2012 @ 11:49:08

    Thanks, it helped.

    Reply

  4. Sathishkumar
    May 07, 2012 @ 09:54:38

    Thanks for the guide..

    Reply

  5. jack
    May 08, 2012 @ 02:07:25

    Don’t forget javaws in your update-alternatives command:

    $ sudo update-alternatives –install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_32/bin/javaws 1
    $ sudo update-alternatives –config javaws

    # Verify the symlinks all point to the new java location
    $ ls -la /etc/alternatives/ja*

    Reply

    • Cem Ikta
      May 09, 2012 @ 12:17:03

      Hi Jack,

      Thanks for your feedback, I forgot to configure java web start.

      Reply

    • Arash
      Jun 17, 2012 @ 09:14:29

      Hi Jack,
      Thanks for your useful comment.

      Reply

  6. Samir
    May 08, 2012 @ 19:45:10

    ThanQ very much, it helped me in installing it in Ubuntu 12.04 with out any problems

    Reply

  7. Vyacheslav Romanenko
    May 09, 2012 @ 01:02:17

    Thanks. After ppa:flexiondotorg/java crashed it was really helpfull.

    Reply

  8. Ondrej
    May 10, 2012 @ 00:59:39

    Thanks! Helped me a lot.

    Reply

  9. Ante Primorac
    May 11, 2012 @ 09:13:12

    Change: sudo update-alternatives –install /usr/bin/java javaws /usr/lib/jvm/jdk1.7.0_04/bin/javaws 1
    to: sudo update-alternatives –install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.7.0_04/bin/javaws 1

    Reply

    • Cem Ikta
      May 11, 2012 @ 11:52:03

      Thanks for your attention.

      Reply

  10. srinivas
    May 16, 2012 @ 08:22:04

    Thanks :)

    Reply

  11. Marcos Maia
    May 17, 2012 @ 14:29:25

    Thanks man, it worked perfectly for me. Can I translate this to portuguese and post in my blog? I will keep the reference to this original post of course.

    regards.

    Reply

    • Cem Ikta
      May 17, 2012 @ 14:34:52

      yes of cource.

      Reply

      • Marcos Maia
        May 18, 2012 @ 19:18:38

        Thank you, I will probably do the translation and post to my blog this weekend. I would also suggest you to add jar configuration to your post as it is needed to manually create archives and also to execute some java programs.

        regards.

        Reply

  12. Ishan Thilina
    May 18, 2012 @ 12:23:18

    Thanks, This works…!

    Reply

  13. mort chase
    May 22, 2012 @ 23:03:37

    New to linux and ubuntu.installled jdk7 on ubuntu12.04 as outlined on this webpage.
    Version checked ok. Tried to use javac and java as:
    javac progname.java =>error cannot read binary files. same with java.progname.
    I have some successful experience with java on windows 7 ,classpath and all, none
    so far on ubuntu/linux2. Would greatly appreciate any help, thanks.
    mort chase

    Reply

    • Cem Ikta
      May 22, 2012 @ 23:46:29

      Please check whether you have installed correct 32-bit/64-bit jdk for your system, I have 64-bit installed.
      Maybe your java file path is wrong? Please check your libs / package / classpath!
      if everything ok but still error occurs, please try with eclipse or netbeans ide, then you can see with eclipse or netbeans better error messages.

      Reply

      • zubair
        Jul 13, 2012 @ 13:12:36

        my system is 64bit running ubuntu12.04..downloaded jdk-7u5-linux-x64.tar.gz from oracle website..i followed all steps and had no problem until step: java -version,
        this gives error: bash: /usr/bin/java: cannot execute binary file
        and similar error messages for javac and javaws.
        plz suggest where is the problem

        Reply

        • Cem Ikta
          Jul 13, 2012 @ 15:01:47

          Have you the correct JDK directory in /usr/lib/jvm/jdk1.7.0_05 ? If you don’t have correct JDK directory, change the java source command paths in “sudo update-alternatives …”.

          Reply

      • Komeng
        Dec 09, 2012 @ 06:59:58

        I was struck by the honesty of your poistng

        Reply

    • mort chase
      May 23, 2012 @ 00:53:40

      Thanks so much Cem Ikta, will try what you suggestred
      regards: mort chase

      Reply

      • mort chase
        Jun 11, 2012 @ 22:43:54

        from mort chase to Cem Ikta:
        Follwed istall- procedures for jdl1.7.0_04 as you outlined above. version ok, mozilla plugins ok,symlinks java, javac and javaws point to new location ok. Version
        1.6.0_24 is ithe one nstalled. Any suggestions regarding $path setup after
        successful installation would help this novice.
        regards: mort chase

        Reply

  14. shetty
    May 24, 2012 @ 06:14:47

    Enable mozilla firefox plugin, to reflect even on chrome :
    32 bit:
    ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/i386/libnpjp2.so ~/.mozilla/plugins/

    64 bit:
    ln -s /usr/lib/jvm/jdk1.7.0/jre/lib/amd64/libnpjp2.so ~/.mozilla/plugins/

    Reply

  15. mohamed
    May 28, 2012 @ 21:24:35

    j’ai bien suivi les intrictions .j’ai abouti bien sur a installer jdk7 sous ubuntu 12.04
    merci de m avoir aider

    Reply

  16. mohamed
    May 28, 2012 @ 21:35:16

    sauf que j’ai noté
    sudo mv jdk1.7.0_04 /usr/lib/jvm/ :donc le jvm va contenir tous les contenus du (jdk1.7.0_04)
    donc le repertoire
    jvm/jdk1.7.0_04/bin/javac 1=jvm/bin ………………..
    jdk1.7.0_04 n’existe pa
    c-a-d :la commande
    sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/jdk1.7.0_04/bin/javac 1
    on la remplace par
    sudo update-alternatives –install /usr/bin/javac javac /usr/lib/jvm/bin/javac 1
    c valable pour les autres commandes

    Reply

    • Cem Ikta
      May 28, 2012 @ 21:44:19

      I have 2 JDK directories: jvm/jdk1.6.0_32 and jvm/jdk1.7.0_04.

      Reply

  17. Stephen
    Jun 03, 2012 @ 19:59:17

    I installed 64 bit version 7 as per all these instructions, I can get Java working in Firefox, but not in Ubuntu 12.04. Java doesn’t show up in the list of programs so I can’t set jar files to open with Java to play Minecraft. When I “search for applications online” it tells me that it needs OpenJDK Runtime 6 or 7 installed. I thought Sun’s Java was meant to this job? Any ideas what I’ve done wrong?

    Reply

    • Cem Ikta
      Jun 03, 2012 @ 21:43:54

      open terminal
      go to the .jar file folder
      type: java -jar filename.jar in the terminal

      Reply

  18. Erit
    Jun 03, 2012 @ 22:24:15

    Muchas gracias. Ya me avia desesperado, Thanks (y)

    Reply

  19. MaxouMask
    Jun 04, 2012 @ 15:43:14

    hi thanks for the guide, very hepful,
    But watchout for x86 architecture, the link for the mozilla plugin is :
    sudo ln -s /usr/lib/jvm/jdk1.7.0_04/jre/lib/i386/libnpjp2.so /usr/lib/mozilla/plugins

    Just replace the amd64 with i386

    Reply

  20. GPatton
    Jun 07, 2012 @ 16:44:01

    Works like a charm , Thanks

    Reply

  21. Java JDK uz (K)Ubuntu 12.04 | Kode
    Jun 13, 2012 @ 12:23:50

    [...] Info ņemts no šejienes: http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/ [...]

    Reply

  22. David
    Jun 16, 2012 @ 17:19:11

    Thanks for the guide really helped me a lot. I did get the error in Eclipse though “java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:” fresh Ubuntu 12.04 32 bit. Thanks to Klau3 for the solution.

    Reply

    • Halili
      Dec 08, 2012 @ 14:10:02

      might guess but thats too easy.a0 Sun JDK6 is now in an archive rroesitpoy, so you need to add that and then, wait for it, your instance hangs. So, Im about to try to fix that, by following

      Reply

  23. Ubuntu 12.04 – install sun jdk 67 - 真実を知ればおのれは自由になる
    Jun 18, 2012 @ 17:41:14

    [...] Ubuntu 12.04 – install sun jdk 6-7. Tagged with: jdk • ubuntu  If you enjoyed this article, please consider sharing it! [...]

    Reply

  24. Abhay
    Jun 23, 2012 @ 00:37:56

    Thanks for guiding it works very well…..
    also tell me how to set System Wide CLASSPATH in UBUNTU 12.04

    Reply

    • Cem Ikta
      Jun 24, 2012 @ 14:55:19

      I’ve added JAVA_HOME configuration. Thank you for remembering.

      Reply

  25. Akseli Palén
    Jun 26, 2012 @ 23:49:53

    Hey jeah, thanks for this! Finally got my Aptana Studio installation to work.

    Reply

  26. Ubuntu 12.04 – install sun jdk 6-7 « linkhalde
    Jun 28, 2012 @ 13:55:51

    [...] Ubuntu 12.04 – install sun jdk 6-7. Posted in Uncategorized.Tagged 12.04, Installation, jdk, [...]

    Reply

  27. mort chase
    Jun 28, 2012 @ 22:36:08

    java-1.6.0-openjdk-i386, java-6-openjdk-i386, java-6-openjdk-common and java-7-openjdk-i386
    came preinstalled on ubuntu12.04 installed at usr/lib/jvm. Are they necessary in addition to the
    above described jdk7u installation or should they be removed?? Or does it not matter etc??

    Reply

    • Cem Ikta
      Jun 28, 2012 @ 22:50:56

      You don’t need openjdk for sun jdk installation. You can uninstall or leave it.

      Reply

  28. mort chase
    Jun 30, 2012 @ 00:51:56

    Thank you Cem Ikta for all the help; things are looking up finally !

    Reply

  29. Steffen
    Jul 05, 2012 @ 17:35:34

    Merci – Thanks – Danke!!!!!

    Reply

  30. titus
    Jul 06, 2012 @ 11:00:52

    At first thank you for your instruction.

    I installed JDK 6 on Ubuntu 12.04. java-6-openjdk was installed former.
    The Test from the java version is ok .
    ——
    java -version
    java version “1.6.0_32″
    Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
    ——
    but I start tomcat6
    I got an error.
    INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:
    /usr/lib/jvm/java-6-openjdk/jre/lib/amd64/server:/usr/lib/jvm/java-6-openjdk/jre/lib/amd64:/usr/lib/jvm/java-6-openjdk/jre/../lib/amd64:/usr/java/packages/lib/amd64:/usr/lib/jni:/lib:/usr/lib
    ———–
    I’m confuse
    what is the problem?

    Reply

  31. Happened after installing Java 1.7.0_05! I had IcedTea before
    Jul 07, 2012 @ 03:45:44

    [...] thx, one more thing: Is this a relyable source?: http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/ I mean can i try to install java 6 from [...]

    Reply

  32. Dave
    Jul 15, 2012 @ 16:33:29

    Great article.

    Reply

  33. Miguel Nunes aka spacemig » Blog Archive » Installing Processing in Ubuntu 12.04
    Jul 24, 2012 @ 07:16:31

    Reply

  34. Tutu
    Jul 24, 2012 @ 15:43:04

    Big THX!

    Reply

  35. George Hadjikyriacou
    Jul 27, 2012 @ 21:31:54

    Nice Post thanks! You can also add jar configuration with:

    sudo update-alternatives –install /usr/bin/jar jar /usr/lib/jvm/jdk1.6.0_32/bin/jar 1

    Reply

  36. fbtb
    Aug 02, 2012 @ 18:19:51

    Thanks for this great Post!
    But which settings are needed to macke Eclipse work with the new JDK? I get errors (Root exception:
    java.lang.IllegalStateException: Profile PlatformProfile is not current. Expected timestamp 0 but was 0.)

    Reply

    • Cem Ikta
      Aug 03, 2012 @ 12:16:34

      If you see right java version in your console(java -version), you do nothing for Eclipse, it works for me for Eclipse Indigo and Juno. Please check your 32/64-bit installation steps.

      Reply

  37. joeyblack
    Aug 03, 2012 @ 07:30:05

    HEY!!!! Thanks for the help! Worked like a charm for jdk1.6.0_33 on Ubuntu 12.04 64 Muchas Gracias

    Reply

  38. Pragya
    Aug 06, 2012 @ 08:35:20

    Hi,
    i have ubuntu 12.4 version 64 bit machine. i am trying to install jdk-6u32-linux-x64.bin file. but getting the error when trying to extract file:
    Checksumming…
    The download file appears to be corrupted. Please refer
    to the Troubleshooting section of the Installation
    Instructions on the download page for more information.
    Please do not attempt to install this archive file.

    i am using following commands:
    chmod +x jdk-6u32-linux-x64.bin
    ./jdk-6u32-linux-x64.bin

    Please help

    Thanks in advance,
    Pragya

    Reply

    • Cem Ikta
      Aug 06, 2012 @ 13:43:16

      I think that the jdk-file was not downloaded correctly. Try to download again.

      Reply

  39. Instalando sun jdk 6 no ubuntu | rneves
    Aug 09, 2012 @ 03:48:33

    [...] para este post um outro blog que também mostra como instalar a versão 7 do java, segue o link da página. Compartilhe:FacebookTwitterPinterest Postado em Instalacao, [...]

    Reply

  40. hamstap85
    Aug 09, 2012 @ 08:11:02

    For setting the JAVA_HOME variable, in this case would the example be /usr/lib/jvm/jdk1.7.0_04 or /usr/lib/jvm/jdk1.7.0_04/bin/java ? I would suspect the former because PATH is that + /bin. Just making sure I got this right, because I heard some places that say to add the /bin/java part to JAVA_HOME

    Reply

    • Cem Ikta
      Aug 09, 2012 @ 13:42:47

      For JDK 6: JAVA_HOME= /usr/lib/jvm/jdk1.6.0_32
      For JDK 7: JAVA_HOME=/usr/lib/jvm/jdk1.7.0_04

      Reply

  41. zrrtcs
    Aug 17, 2012 @ 10:19:22

    any idea how to update the javadoc/javah/javap or is it unnecessary?
    thanks a lot for the information. sucks that oracle doesnt allow ubuntu to install their jdks easily

    $ ls -la /etc/alternatives/java*
    lrwxrwxrwx 1 root root 33 Aug 17 16:04 /etc/alternatives/java -> /usr/lib/jvm/jdk1.6.0_32/bin/java
    lrwxrwxrwx 1 root root 34 Aug 17 16:03 /etc/alternatives/javac -> /usr/lib/jvm/jdk1.6.0_32/bin/javac
    lrwxrwxrwx 1 root root 44 Aug 5 03:24 /etc/alternatives/javadoc -> /usr/lib/jvm/java-6-openjdk-i386/bin/javadoc
    lrwxrwxrwx 1 root root 54 Aug 5 03:24 /etc/alternatives/javadoc.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javadoc.1.gz
    lrwxrwxrwx 1 root root 42 Aug 5 03:24 /etc/alternatives/javah -> /usr/lib/jvm/java-6-openjdk-i386/bin/javah
    lrwxrwxrwx 1 root root 52 Aug 5 03:24 /etc/alternatives/javah.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javah.1.gz
    lrwxrwxrwx 1 root root 42 Aug 5 03:24 /etc/alternatives/javap -> /usr/lib/jvm/java-6-openjdk-i386/bin/javap
    lrwxrwxrwx 1 root root 52 Aug 5 03:24 /etc/alternatives/javap.1.gz -> /usr/lib/jvm/java-6-openjdk-i386/man/man1/javap.1.gz
    lrwxrwxrwx 1 root root 35 Aug 17 16:04 /etc/alternatives/javaws -> /usr/lib/jvm/jdk1.6.0_32/bin/javaws

    $ sudo update-alternatives –config javadoc
    There is only one alternative in link group javadoc: /usr/lib/jvm/java-6-openjdk-i386/bin/javadoc
    Nothing to configure.

    Reply

    • Cem Ikta
      Aug 17, 2012 @ 12:45:10

      Not sure, but as far as I know it is not necessary! Eclipse or NetBeans has javadoc settings.

      Reply

      • zrrtcs
        Aug 20, 2012 @ 13:37:39

        yeah youre right. thanks

        Reply

  42. How to update sun jdk 7 on Ubuntu 12.04
    Aug 20, 2012 @ 18:25:23

    [...] 6 with JavaFX 2.2 Final for GNU/Linux, Mac OS X and MS Windows last week. I have already written how to install Sun JDK 6-7 on Ubuntu 12.04. I want to write how to update JDK 7 Update 6 [...]

    Reply

  43. Pablo
    Aug 28, 2012 @ 09:24:52

    Thank you men
    After almot 7 hours this was the final solution to my big problem, i think i will recommend you

    Reply

  44. Danny
    Aug 31, 2012 @ 01:00:47

    Excellent guide, just worked! Thanks.

    Reply

  45. AngryNerd» Blog Archive » 在Ubuntu 12.04 LTS下布置Android开发环境
    Sep 03, 2012 @ 07:36:14

    [...] 手动安装,太麻烦了,我缩了,欢迎有兴趣有胆色的朋友请自己动手一试; [...]

    Reply

  46. UBUNTU JDK KURULUMU « Gokhan Yılmaz
    Sep 10, 2012 @ 19:25:01

    [...] java -version komutundan yararlanarak versiyonumuzu kontrol ediyoruz ve aldığımız sonuç : java version "1.6.0_32" Java(TM) SE Runtime Environment (build 1.6.0_32-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode) şeklinde olmalıdır. Değilse lütfen yaptığınız işlemleri kontrol edin… Kaynaklar: http://codingforme.wordpress.com/2012/05/14/installing-oracle-java-jdk-6-or-7-on-ubuntu-12-04/ http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/ [...]

    Reply

  47. [HOW-TO] Set up a build environment for CM10 - Page 2
    Sep 12, 2012 @ 20:41:40

    [...] times You may want to add this to the op too Ubuntu 12.04 – install sun jdk 6-7 and "apt-get install libxml2-utils" to install [...]

    Reply

  48. How to install Oracle JDK 6 in Ubuntu Server 12.04 via apt-get command line? | A Quest for Technical Expertise
    Sep 25, 2012 @ 11:59:03

    [...] Ubuntu 12.04 – install sun jdk 6-7: http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7 [...]

    Reply

  49. Onur
    Oct 11, 2012 @ 13:54:47

    Teşekkürler, çok güzel açıklamışsınız.

    Reply

  50. fj
    Oct 13, 2012 @ 07:46:58

    thanks :)

    Reply

  51. sunil
    Oct 21, 2012 @ 15:46:40

    Thanks a lot :)

    Reply

  52. Anoop Aravind
    Nov 14, 2012 @ 08:20:16

    Waouuuu… its so simple to execute…thanksss so much dude!!!!

    Reply

  53. Sachin
    Dec 19, 2012 @ 18:52:48

    Thankas a ton. This document helped me a lot.:)

    Reply

  54. Bill Littman
    Dec 28, 2012 @ 20:03:46

    Terrific post. Very helpful. One personal preference: instead of editing .bashrc, I add the following lines to /etc/environment (this will set up java for all users of the machine):

    JAVA_HOME=/usr/lib/jvm/jdk1.7.0_10/
    PATH=”/usr/local/sbin:………..:$JAVA_HOME/bin”

    Reply

  55. Gubs
    Mar 05, 2013 @ 18:35:11

    Hi,

    1) In the given instruction on installing sun java 6 the command mentioned for `mv jdk../ /usr/lib/jvm/`. Can you please remove the “/” on primary jdk folder. Because, it moved the files and folders inside jdk into jvm.

    2) In .bashrc you can have below. Its easy to add JAVA_HOME from bin/java.
    export JAVA_HOME=$(readlink -f /usr/bin/java | sed “s:bin/java::”)
    export PATH=$PATH:$JAVA_HOME/bin

    Reply

    • Cem Ikta
      Mar 07, 2013 @ 13:59:58

      Hi,

      Thanks for your feedback.

      I have 2 separate JDK directories in my system and with move commands as below:

      sudo mv jdk1.6.0_38 /usr/lib/jvm/jdk1.6.0_38
      sudo mv jdk1.7.0_11 /usr/lib/jvm/jdk1.7.0_11

      If you only need one JDK you can directly copy it to /usr/lib/jvm.

      Best regards.

      Reply

  56. Eclipse | Annotary
    Apr 18, 2013 @ 13:10:22

    [...] Web Development Property-Legals IRCTC Tips & Trick Home Loan Sort Share http://www.devsniper.com       4 minutes [...]

    Reply

  57. Arif Ali Saiyed
    Apr 18, 2013 @ 13:11:22

    Thanks you very much putting up this article.
    This turn out to be life saver.
    I tried installing and ‘alien’ but somehow that did not work, it dint even copy the files to /usr

    thanks a ton

    Reply

  58. Kris
    May 23, 2013 @ 21:02:29

    Thanks. I hate that Ubtuntu no longer has an easy way to install sun-jdk from repos. Your instructions where very helpful in overcoming that obstacle to keep using Ubuntu :-)

    Reply

    • Cem Ikta
      May 24, 2013 @ 13:02:05

      I think because of license issues.

      Reply

  59. Husmukh
    May 26, 2013 @ 08:46:16

    Thank you very much. This post is very informative and helpful.

    Reply

  60. Installing Sun JDK 6 on Ubuntu 12.04 | Ungeek Traveler
    Jun 18, 2013 @ 16:08:10

    [...] When I want to install hadoop, hive, R, and RHive, the dependencies is JDK, previously I use embedded java from linux package, but, it doesn’t work well, so I try to install Sun JDK downloaded from Oracle, by using the reference from here [...]

    Reply

  61. wijaz
    Aug 03, 2013 @ 14:48:59

    yes it helps a lot

    Reply

  62. Jovanny
    Aug 11, 2013 @ 00:10:26

    Muchísimas gracias por la información!!

    Reply

  63. Ставим Apache OFBiz на Ubuntu Server 12.4 LTS « Интересно почитать…
    Aug 14, 2013 @ 01:35:00

    [...] вот вроде инструкция для установки JDK6 на Ubuntu: http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/. Этот jdk-6u45-linux-i586.bin судя по всему просто на просто [...]

    Reply

  64. UBUNTU JDK KURULUMU | Gökhan YILMAZ
    Aug 15, 2013 @ 12:32:53

    [...] java -version komutundan yararlanarak versiyonumuzu kontrol ediyoruz ve aldığımız sonuç : java version "1.6.0_32" Java(TM) SE Runtime Environment (build 1.6.0_32-b05) Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode) şeklinde olmalıdır. Değilse lütfen yaptığınız işlemleri kontrol edin… Kaynaklar: http://codingforme.wordpress.com/2012/05/14/installing-oracle-java-jdk-6-or-7-on-ubuntu-12-04/ http://www.devsniper.com/ubuntu-12-04-install-sun-jdk-6-7/ http://wiki.ubuntu-tr.net/index.php/U%C3%A7birim [...]

    Reply

  65. My ubuntu developer pc: installations and settings
    Aug 30, 2013 @ 18:08:08

    [...] See my blog post: Ubuntu 12.04 – install sun jdk 6-7 [...]

    Reply

  66. Anthony
    Sep 14, 2013 @ 18:37:10

    Very nice article!

    About the mozilla plugin installation at the end, couldn’t you use the same update-alternative method instead of adding a symlink in /usr/lib/mozilla/plugins and leaving the openjdk symlink there?

    64 bit:
    sudo update-alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /usr/lib/jvm/jdk1.7.0_11/jre/lib/amd64/libnpjp2.so 1

    32 bit:
    sudo update-alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so mozilla-javaplugin.so /usr/lib/jvm/jdk1.7.0_11/jre/lib/i386/libnpjp2.so 1

    sudo update-alternatives –config mozilla-javaplugin.so

    Reply

    • Cem Ikta
      Sep 16, 2013 @ 09:34:56

      Hi Anthony,

      Thanks for your feedback, but I don’t use OpenJDK!

      Reply

      • Anthony
        Sep 16, 2013 @ 16:46:45

        Hi Cem,

        I meant that instead of adding sun java plugin in /usr/lib/mozilla/plugins as a symlink and leaving the openjdk plugin there too, to use the update-alternatives method so you can switch from openjdk and sun all 3 binaries and the browser plugin with just update-alternatives:

        sudo update-alternatives –config javac
        sudo update-alternatives –config java
        sudo update-alternatives –config javaws
        sudo update-alternatives –config mozilla-javaplugin.so

        Not sure it’s proper but it’s convenient! :)

        Reply

  67. STORM and Cassandra Installation and Integration | Sreeram Chintalapudi
    Mar 19, 2014 @ 07:14:53

    Reply

  68. Kannan
    May 06, 2014 @ 12:53:07

    Thank you so much… I have been rolling through internet for this long time… It is simply very clear and your commands on why to run each command were very useful to understand.
    Once again thanks.. :)

    Reply

Leave a Reply