PDF download Download Article PDF download Download Article

Do you need to run Java programs on Ubuntu? Perhaps you want to use Java to create applications. Java is a general-purpose programming language that is designed to run on any platform with as few dependencies as possible. Java Runtime Environment (JRE) allows you to run Java applications on your computer. Java Development Kit (JDK) allows you to write and compile programs in Java. You can easily install Open Java using the Terminal. You can also install Oracle Java, which has some additional commercial features using a different software repository in the Terminal. This wikiHow teaches you how to install Java using the Terminal on Ubuntu.

Method 1
Method 1 of 4:

Installing Open Java Run Time Environment

PDF download Download Article
  1. This is the keyboard shortcut to open the Terminal in Ubuntu.
    • Alternatively, you can click the Terminal icon in the Apps menu. It has an icon that resembles a black screen with a white cursor.
  2. This updates the "apt" software repository so that you are running the latest version.
    • If prompted to do so, enter your Ubuntu user password and press Enter .
    Advertisement
  3. This checks if Java is already installed on your computer. If Java is already installed, it will display which version of JDK and JRE you have installed. If Java is not already installed, it will say "'Java', not found." [1]
  4. This is the command to install the latest version of Java Runtime Environment on your Ubuntu system. Java Runtime Environment allows you to run Java applications on your computer.
  5. This confirms that you want to install Java Runtime Environment and installs the latest version of Java Runtime Environment.
    • You can verify your Java installation using the "java -version" command.
  6. Advertisement
Method 2
Method 2 of 4:

Installing Open Java Development Kit

PDF download Download Article
  1. This is the keyboard shortcut to open the Terminal in Ubuntu.
    • Alternatively, you can click the Terminal icon in the Apps menu. It has an icon that resembles a black screen with a white cursor.
  2. This updates the "apt" software repository so that you are running the latest version.
    • If prompted to do so, enter the user password you use to log in to Ubuntu.
  3. This checks if Java is already installed on your computer. If Java is already installed, it will display which version of JDK and JRE you have installed. If Java is not already installed, it will say "'Java', not found."
  4. This is the command to install the latest version of Java Development Kit on your Ubuntu system. Java Development Kit allows you to write applications using the Java programming language.
    • If you want to install a specific version of Java, you can do so using the following command: sudo apt install openjdk-#-jdk . Replace "#" with the version of Java you want to download (i.e. "8" to install JDK 8).
  5. This confirms that you want to install Java Runtime Environment and installs Java Development Kit.
    • You can verify your Java installation using the "java -version" command.
  6. Advertisement
Method 3
Method 3 of 4:

Installing Oracle Java

PDF download Download Article
  1. This is the keyboard shortcut to open the Terminal in Ubuntu.
    • Alternatively, you can click the Terminal icon in the Apps menu. It has an icon that resembles a black screen with a white cursor.
  2. This updates the "apt" software repository so that you are running the latest version.
    • If prompted to do so, enter the user password you use to log in to Ubuntu.
  3. This checks if Java is already installed on your computer. If Java is already installed, it will display which version of JDK and JRE you have installed. If Java is not already installed, it will say "'Java', not found."
  4. This installs the properties needed to add the software repository needed to install Oracle Java.
  5. This installs the software repository that is needed to install Oracle Java.
    • Alternatively, you can install Oracle Java from the "Webupd8" software repository. Use the following command to do so: sudo add-apt-repository ppa:webupd8team/java
    • If prompted to do so, enter the password you use to log in to Ubuntu and press Enter.
  6. This updates the repository so that you are running the latest version.
  7. This is the command to install the latest version of Java. [2]
    • If you want to install a specific version of Java, replace the "11" with the version number you want to install (i.e. Java10).
  8. This confirms that you want to install Oracle Java.
  9. To do so, scroll down to the bottom of the text document and select Ok' and press Enter . Then select Yes and press Enter . This completes the Java installation.
  10. Advertisement
Method 4
Method 4 of 4:

Setting a Default Version of Java

PDF download Download Article
  1. This is the keyboard shortcut to open the Terminal in Ubuntu. If there is more than one version of Java installed on your Ubuntu system, you can specify which version you want to use as the default version.
    • Alternatively, you can click the Terminal icon in the Apps menu. It has an icon that resembles a black screen with a white cursor.
  2. This displays all versions of Java currently installed on your Ubuntu system. Each version is listed by a numbered mode.
  3. This sets the Java version you selected as the default version of Java.
  4. Advertisement

Expert Q&A

Ask a Question
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!

      About This Article

      Thanks to all authors for creating a page that has been read 24,997 times.

      Is this article up to date?

      Advertisement