Install Oracle Java 6, 7, or 8 in Ubuntu 14.04 Trusty

Last updated: September 18, 2014

Oracle Java Ubuntu 14.04

This simple tutorial is going to show you how to easily install Oracle Java (JDK) 6, 7, or 8 in Ubuntu 14.04 Trusty Tahr via PPA.

There’s a Launchpad PPA (Personal Package Archive) maintained by webupd8.org, a popular Ubuntu Linux blog, which provides the most recent installers to automatically download and install Oracle Java JDK6 / JDK7 / JDK8 from oracle website. Note there are no actual Java files in this PPA.

To get started:

Press Ctrl+Alt+T on your keyboard to open a terminal window. When it opens, copy and paste the command below and hit enter. Input your user password when prompts and it will add the PPA repository into your system.

sudo add-apt-repository ppa:webupd8team/java

After that, update package lists via:

sudo apt-get update

To install Oracle Java 8, run:

sudo apt-get install oracle-java8-installer

Change the number 8 to 6 (or 7) in the code to install Java 6 (or 7).

While installation, you’ll be asked to agree the license and then the installer start downloading Java file from oracle website and install it on your system.

To set the default Java, run:

sudo apt-get install oracle-java8-set-default

Also change number 8 to the Java version you want.

Finally check whether everyting is OK:

java -version

It will output something like below:

java version “1.7.0_60”
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

Twitter

I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee: https://ko-fi.com/ubuntuhandbook1 |

35 responses to Install Oracle Java 6, 7, or 8 in Ubuntu 14.04 Trusty

  1. Good job bro :)

  2. something gonne bad installing Java 8, it wont finish the update when i run:
    sudo apt-get install oracle-java8-installer
    so i can`t update my 14.04 it gives me just partial upgrade…

    can you help, Thank you in advance and kind regards

    • Have you tried scrolling down i did that and found out it was done!

      • Looks like some dependencies are broken with the latest updates – trying to install via apt gives:

        The following packages will be REMOVED:
        apt apturl nautilus-share python-software-properties python3-software-properties software-center software-properties-common software-properties-gtk ubuntu-desktop ubuntu-extras-keyring ubuntu-minimal unattended-upgrades
        The following NEW packages will be installed:
        oracle-java8-installer

  3. Seems that this tries to remove apt for me on 14.04:
    Suggested packages:
    binfmt-support visualvm ttf-baekmuk ttf-unfonts ttf-unfonts-core ttf-kochi-gothic ttf-sazanami-gothic
    ttf-kochi-mincho ttf-sazanami-mincho ttf-arphic-uming
    The following packages will be REMOVED:
    apt apturl nautilus-share pgdg-keyring postgresql-9.1 postgresql-client-9.1 postgresql-client-common
    postgresql-common python3-software-properties software-center software-properties-common
    software-properties-gtk tasksel tasksel-data ubuntu-desktop ubuntu-extras-keyring ubuntu-minimal
    unattended-upgrades
    The following NEW packages will be installed:
    oracle-java8-installer
    WARNING: The following essential packages will be removed.
    This should NOT be done unless you know exactly what you are doing!
    apt

  4. I don’t think this will work with 14.04 (currently in beta). Following the instructions above, I get this:

    The following packages will be REMOVED
    apt apturl nautilus-share python3-software-properties software-center software-properties-common
    software-properties-gtk ubuntu-desktop ubuntu-extras-keyring ubuntu-minimal unattended-upgrades

    In other words, it would uninstall the Ubuntu desktop!

  5. The following packages will be REMOVED:
    apt apturl nautilus-share python3-software-properties software-center software-properties-common
    software-properties-gtk ubuntu-desktop ubuntu-extras-keyring ubuntu-minimal unattended-upgrades

    This package appears to destoy Ubuntu 14.04?

    • Thanks guys. I’ve report this issue to the PPA maintainer. There will be an update soon.

  6. Now, it works fine in Ubuntu 14.04, thanks :)

  7. Hello,

    i have installed it severeal times, but i have to uninstalled it, and icedtec. Because all times java was blocked or not working properly.

    • i may meet the same problem,the situation is that i can compiling the procedure,when i use the order_ “java” and it does’t work ,the reason is “can not find the main class XXXX”,but when i do the same work on windows7, it’s ok to accomplish the procedure,so i think the problem is $JAVA_HOME ,because When I was check java installation directory i find that i have no limit to inside the directory, now it still not work….

  8. Very thorough and accurate manual (14.04). The very first time java wasn’t a pain installing. Thank you.

  9. sudo apt-get install oracle-java7-installer

    Tried this on 14.04, but I am getting:

    The following packages have unmet dependencies:
    oracle-java7-installer : Depends: java-common (>= 0.24) but it is not going to be installed
    Recommends: gsfonts-x11 but it is not going to be installed

    • Seems that you have broken packages. Try:

      sudo apt-get update
      
      sudo apt-get -f install

      Find out what is broken and fix it.

      • Jean-Victor Côté July 19, 2015 at 7:05 pm

        I had the same problem, including the same problem with binutils, and tried the two lines that you provided, to no avail. Is it possible that the 64 bit version is not yet ready?

  10. How can I selectively install 32-bit JDK? Given command installs 64-bit JDK.
    P.S. – I’m trying to develop an Android app and I was told to install 32-bit JDK.

    • I think it automatically detects your arch. because I have used this command on a 64bit Trusty and am installing it on a 32bit Precise as I type.

  11. Hi Ji m,

    I’m new bee for ubuntu..

    I’m using ubuntu 14.04 LTS and i want to install java 6u21 in this.

    How to install exact version and update only..

    • First it’s highly recommended to install the latest stable version as it is compatible with older versions. If an application or web page you access requires an older version of Java, you should report this to the provider/developer and request that they update the application to be compatible with all Java versions.

      Second, if you really want the java 6u21, you can download the official installer from THIS PAGE.

      • 32-bit system download the “jre-6u21-linux-i586.bin”
      • 64-bit system download the “jre-6u21-linux-x64.bin”

      Once downloaded, press Ctrl+Alt+T on keyboard to open the terminal and do:

      1. Go to the Downloads folder and give executable permission:

      cd ~/Downloads/ && chmod u+x jre-6u21-linux-*.bin

      2. Run the installer:

      ./jre-6u21-linux-*.bin

      3. Move the installation to /usr/lib/jvm:

      sudo mv jdk1.6.0_21 /usr/lib/jvm/

      If /usr/lib/jvm is not exist, create it by:

      sudo mkdir -p /usr/lib/jvm

      4. To make it default (depends on OS type, you may change i386 to amd64):

      sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_21/bin/java" 1
      sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_21/bin/javac" 1
      sudo update-alternatives --install "/usr/lib/mozilla/plugins/libjavaplugin.so" "mozilla-javaplugin.so" "/usr/lib/jvm/jdk1.6.0_21/jre/lib/i386/libnpjp2.so" 1
      • On my 14.04 system, the plugins are in /usr/lib/firefox-addons/plugins not /usr/lib/mozila/plugins so I had to change the update-alternatives command.

        Thanks for posting that info: it saved me some time because I bailed out of the webupd8 software when it insisted on re-downloading the install package that I’d already downloaded and installed. Without it, I would have needed to do other searching to find out what I needed to do to finish the install.

  12. Great :) Ji m………..,

    The step you provide it looks great and it perfect for Ubuntu New bee like me.

    Thanks lot for your support…

  13. thanks lot to your simple steps to install java in ubuntu. It made to save lot time.

  14. Great, it’s working! Please consider the one step more in yout tutorial, to check whether everyting is OK. I have used:
    java -version
    And the output:
    java version “1.8.0_20”
    Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
    Java HotSpot(TM) Server VM (build 25.20-b23, mixed mode)

  15. Cannot add PPA: ‘ppa:webupd8team/java’.
    Please check that the PPA name or format is correct.

    Please tell me how to solve this error

    • Try below steps to fix the issue:

      1. Make sure you’re not behind proxy.
      2. Run command:

      sudo apt-get install --reinstall ca-certificates

      3. Use below command instead to add the PPA:

      sudo -E add-apt-repository ppa:webupd8team/java
  16. 32 bit JDK instructions are needed here.

  17. How to play movies in ubuntu???

    • Open Ubuntu Software Center, search for and install ubuntu-restricted-extras allows you to watch video files in common formats via the default Movie Player. Or you can search for and install VLC video player.

  18. hey dude. i know that its not the right place at all, but ive seen your links most of the places while surfing. since i didnt got anywhere im asking my question here. How to view my android screen in my ubuntu 14.04 LTS 64 bit. as i told its not a right place to ask but some other tutorials tell that u have to get the latest java on your system and do bla bla bla. i just rooted my phone and it has no problem as there are many apps like droid vnc, webkey,etc. but the tablet i got, i just couldnt root it as i got no information about its rooting. it is Intel Tablet Pc TM 105 Mg series. got Intel Atom processor and Intel Midfield CPU. runs on android version 4.0.4 Icecream Sandwitch. got 1.6 GHz and 1 gb ram. 16 gb internal. Built no 30139. Kernel version INTEL*MEDFIELD PROCESSOR 3.0.8 jenkins@ecs-l2-build#1 SMP PREEMPT Wed Mar 26 10:45:01 HKT 2014 & got IFWI version 05.D5………. plz any one help me either to root my tablet or suggest any other working ways to view my tab’s screen on my pc. I would thank the one who would tell me any method to root the tab coz’ i’ve tried each and every methods available since 7 days till now and counting. now i just want to get rid out this problem. just bought the tab by its look( cursing myself ).

  19. Great instructions. I am a total newbie and didn’t realize there was a space between the java -version. I was typing it java-version. Once I put the space in it worked.

  20. How to remove the previous installed java 8. It’s showing that having error.
    “The package jdk1.8.0.-60 needs to be reinstalled.”
    I spend two or three day to solve it .
    Please advice for.it.

  21. hey ! what to do if the window is not taking the password we input after the first step . Please help

    • For security reason, there’s no feedback when you’re typing a password, just type in mind and hit Enter to get pass.