How to Install JDK in Linux

This wikiHow teaches you how to install the latest version of JDK (Java 12) on Debian, Ubuntu, and Linux Mint using the Linux Rising PPA repository. Press to open a new terminal window. If you're already at the command prompt, just skip to...
Method 1 of 2:

Using Ubuntu or Linux Mint

  1. How to Install JDK in Linux Picture 1How to Install JDK in Linux Picture 1
    Press Ctrl+Alt+T to open a new terminal window. If you're already at the command prompt, just skip to the next step.
  2. How to Install JDK in Linux Picture 2How to Install JDK in Linux Picture 2
    Type sudo add-apt-repository ppa:linuxuprising/java and press Enter. This adds the Linux Uprising repository.[1]
  3. How to Install JDK in Linux Picture 3How to Install JDK in Linux Picture 3
    Type sudo apt update and press Enter. Now that the repository is ready, you can use it to install JDK.
  4. How to Install JDK in Linux Picture 4How to Install JDK in Linux Picture 4
    Type sudo apt install oracle-java12-installer and press Enter. JDK is now installed.
  5. How to Install JDK in Linux Picture 5How to Install JDK in Linux Picture 5
    Type sudo apt install oracle-java12-set-default and press Enter. This sets Java 12 as the default Java version.
    1. To double-check the default version, type java --version at the command prompt and press Enter.
Method 2 of 2:

Using Debian

  1. How to Install JDK in Linux Picture 6How to Install JDK in Linux Picture 6
    Press Ctrl+Alt+T to open a new terminal window. If you're already at the command prompt, just skip to the next step.
  2. How to Install JDK in Linux Picture 7How to Install JDK in Linux Picture 7
    Type su - and press Enter.
  3. How to Install JDK in Linux Picture 8How to Install JDK in Linux Picture 8
    Add the Linux Uprising repository. Here's how:
    1. Type echo "deb http://ppa.launchpad.net/linuxuprising/java/ubuntu bionic main" and press Enter.
    2. Type apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 73C3DB2A and press Enter.
  4. How to Install JDK in Linux Picture 9How to Install JDK in Linux Picture 9
    Type apt-get update and press Enter.
  5. How to Install JDK in Linux Picture 10How to Install JDK in Linux Picture 10
    Type apt-get install oracle-java12-installer and press Enter.
  6. How to Install JDK in Linux Picture 11How to Install JDK in Linux Picture 11
    Type exit and press Enter. JDK is now installed.
  7. How to Install JDK in Linux Picture 12How to Install JDK in Linux Picture 12
    Type sudo apt install oracle-java12-set-default and press Enter. This sets Java 12 as the default Java version.
    1. To double-check the default version, type java --version at the command prompt and press Enter.
3.5 ★ | 2 Vote