Installation of Oracle Java 7 to Ubuntu 13.10, 13.04, 12.04 (JavaFX is included in the installation)

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

1. To add our PPA and install the latest Oracle Java (JDK) 7 in Ubuntu, use the commands below:

#sudo add-apt-repository ppa:webupd8team/java
#sudo apt-get update && sudo apt-get install oracle-jdk7-installer

2. Check if Ubuntu uses Java JDK 7

#java -version

If all went right the answer should be something like this:
java version “1.7.0_07″
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)
Java HotSpot(TM) Server VM (build 23.3-b01, mixed mode)

3. Check what compiler is used:

#javac -version

The correct answer should be like this:
javac 1.7.0_07

4. Adding JAVA_HOME to environment
Edit /etc/environment and add JAVA_HOME=/usr/lib/jvm/java-7-oracle to the end of the file.
First open a Terminal (Applications → Accessories → Terminal), then enter:

#sudo gedit /etc/environment

Append to the end of the file:
JAVA_HOME=/usr/lib/jvm/java-7-oracle

5. Removing Oracle JDK 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-jdk7-installer

if you like this message, you can donate some amount to me 🙂

61 Comments

  1. Good one. Thx

    • Welcome!

      • Thanks ig – I am also Ig – this is what I’ve been looking for.

      • Thanks a lot!
        Complete instruction in one place and up to date! Your article is awesome!
        And here is “donate click” for your job! 😀

        • I start getting “command not found” at update-alternatives-display java, and everything after that… any help?

          • make sure to change –display into –display

          • it seems like this page formats double dash (- -, without spaces) into a single character. Replace –display with – -display (delete space between dashes).

  2. Good one. Thx.
    Launch first
    $ sudo apt-get install software-properties-common
    if u get “add-apt-repository command not found” (ubuntu 12.10 server)

  3. Gaurav Sharma

    Nice Script.
    But the JAVA_HOME environment variable was not created..
    I did check the /etc/environment file
    Also used command “echo $JAVA_HOME”

    • Sushant

      This is a very useful tutorial.

      Mr. Sharma,
      As per the tutorial, write $sudo gedit /etc/environment
      Once it opens, add JAVA_HOME=. Donot put any quotation mark. Then go for $echo $JAVA_HOME

      • vijender thakur

        when i run sudo gedit/etc/environment , i am getting command not found in ubuntu 12.04 . Help me please

        • Vijender,
          ‘sudo’ is a command to run another command as a different user (root by default). ‘gedit’ is a command to run the text editor. ‘/etc/environment’ is a config file to be edited, and is an argument to gedit. There must be a space between gedit and the filename. You may want to look at a basic bash tutorial or something. Good luck.

  4. Thanks a lot.

  5. bonitarunner

    Nice! I am a novice, does this need an extra dash to work?

    #update-alternatives –display java

    I ran this with success.
    $sudo update-alternatives --display java

    Thanks.

  6. Abhijith S J

    thanks a lot. 🙂

  7. THanks 🙂 it worked 🙂

  8. update-alternatives –display java
    produced:
    update-alternatives: error: unknown argument `–display'

    update-alternatives --display java
    worked.

  9. bernboy

    Great! It works in less than 5mins

  10. This helped me out bigtime. Thanks a lot.

  11. Thank you! Helped a lot.

  12. Sarnath

    But When I open Netbeans 7.3 it says “The JDK is missing and is required to run some NetBeans modules Please use the –jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information.”

  13. Thanks for this and for the informative feedback from your visitors – it helped me out quite a bit.

  14. Sachin

    Thank’s a lot!!!!!!!!!

  15. Michelle

    Great help! Very clear and to the point! I am going to put the link on my blog.

  16. thanasis

    i have added JAVA_HOME to environment, and the file looks like:

    PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games” JAVA_HOME=/usr/lib/jvm/java-7-oracle

    is anything missing or it is ok?

    • I have the same settings:

      PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games”
      JAVA_HOME=/usr/lib/jvm/java-7-oracle

      • I did the follow to get it to work via http://bash.cyberciti.biz/guide//etc/profile.d

        1.) created a file called oracle-java.sh in /etc/profile.d
        #sudo gedit /etc/profile.d/oracle-java.sh

        2.) add the following line into the newly created document:
        export JAVA_HOME=/usr/lib/jvm/java-7-oracle

        3.) When you restart the system, all changes will take effect

        • Instead of restarting the system, you can simply source the profile file:

          #source /etc/profile

          The changes will take place immediately. You can verify this by opening a new bash and inputting the following command:

          #echo $JAVA_HOME

      • thanasis

        thanks for the answer ig. I’ve followed the instructions and checked if i ‘ve taken the right messages, but as i tried to run application ModellusX that needed the newestjava version, i took the following msg, that actually means that something was wrong with the installation:

        java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: Can’t load library: /home/thanasis/ModellusX/i386/libglass.so

        at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:281)
        at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:124)
        at javafx.embed.swing.JFXPanel.initFx(JFXPanel.java:182)
        at javafx.embed.swing.JFXPanel.(JFXPanel.java:199)
        at Modellus.WinUI.Animator.AnimationPanel.(AnimationPanel.java:37)
        at Modellus.WinUI.InternalFrames.AnimatorInternalFrame.(AnimatorInternalFrame.java:25)
        at Modellus.WinUI.ModellusFrame.ModellusFrame.createAndShowGUI(ModellusFrame.java:302)
        at Modellus.WinUI.ModellusFrame.ModellusFrame.access$100(ModellusFrame.java:41)
        at Modellus.WinUI.ModellusFrame.ModellusFrame$8.run(ModellusFrame.java:327)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:688)
        at java.awt.EventQueue$3.run(EventQueue.java:686)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

        Can you give some help?

  17. somewone

    The uninstall command doesn’t work

  18. Is it possible to add a package to install the EE components also?

  19. knofiller

    thanks a lot. It should be at step 2:
    #update-alternatives –-display java

  20. Thank you very much

    really it helps

  21. Ibrahim

    thankyou
    it is work

  22. Thanks…It was very helpful for me….

  23. thanks a lot! Simple and fast solution :]

  24. which apt-get install option will install this Java environment version : java version “1.6.0_43”
    Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
    Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)

    Oms

  25. thx a lot

  26. thanks

  27. DaniValenzuela

    good one =D ty!!

  28. Thanks very much, it helps me a lot

  29. This process doesn’t work any more.. Oracle have locked down access to content. In order to download form this site you need to be logged in to Oracle site with registered user.

  30. ashutosh

    Thank.. it works fine.

  31. Laurynas

    Thank you kind sir, you helped me!

  32. Ty for everything

  33. where to put in these commands?

  34. Philippe Heer

    Thanks a lot but one important command was missing

    sudo apt-get install ia32-libs

    Then everything worked super fine:)

  35. hello , i have jdk setup for ubuntu . in that setup even i dont have sh file . then how i install that setup. i dont want to install through repository.

    one more problem i want to know how to install any application in ubutnu while we have setup not by repository.
    please help somebody

  36. thanks

  37. some truly nice and useful info on this web site , also I conceive the layout has great features.

  38. Sir! Thank you so much!!

  39. This is still working for Ubuntu 13.10 also… Good one. keep it up.

  40. Thank you very much!

  41. Your wrong.
    Your title lures people in that are struggling with the real problem regarding installing java on ubuntu.

    In your title you promise installation directions for java SDK. But this is not regarding SDK! Its not even for JDK, its just for the run time server (JRE)

    JDK is developers verion SE
    SDK is developers verion EE.

    For these versions there are no installers available, as far as I can see, but its definitely not the installer you described here.

Trackbacks/Pingbacks

  1. Steps to install Hadoop « Learn Hadoop - [...] Install JDK 7 in Ubuntu [...]
  2. My Development Apps | My Ubuntu Day - [...] Java JDK: I’ve followed that article [...]
  3. Install some necessary programs for your Ubuntu | asteroidb612andmore - [...] java Install Java JDK 7 on Ubuntu 12.04 (JavaFX is included in the installation) [...]
  4. Installing Java in Ubuntu Via Command Line | Ycsoftware.net - [...] http://www.blogs.digitalworlds.net/softwarenotes/?p=41 [...]
  5. [우분투] Oracle JDK7 설치 | Wish - Computer Information - [...] Posted  by ig on Jan 28, 2013 in Java, JavaFX, Ubuntu | 43 comments [...]
  6. ลง Java JDK 7 ใน Ubuntu 12.04 - [...] : http://www.blogs.digitalworlds.net/softwarenotes/?p=41 Java, Linux, [...]
  7. Install Java JDK 7 on Ubuntu 12.04 (JavaFX is included in the installation) | Senouf.fr Conseil Systèmes et Réseaux - […] Install Java JDK 7 on Ubuntu 12.04 (JavaFX is included in the installation) […]
  8. Preparing the development environment for Java – Windows and Ubuntu | Andrei Rinea's technical blog - […] easy one is described at ‘Install Java JDK 7 on Ubuntu 12.04 (JavaFX is included in the installation)‘. Basically…
  9. Developing Android APP on a Ubuntu 12.04 Desktop Environment | Sunfine Data - […] the instructions in “Installation of Oracle Java SDK 7 on Ubuntu 12.04 (JavaFX is included in the installation)“.  The…

Leave a Reply

Your email address will not be published. Required fields are marked *