How to install the JDK on Ubuntu Linux

0 votes
I am trying to install the Java Development Kit (JDK) on Ubuntu Linux distribution, but I am unable to install it.

What are the steps to install it on Ubuntu?
Dec 30, 2020 in Java by Roshni
• 10,480 points
176 views

1 answer to this question.

0 votes
  1. Open Terminal from Application Dash or press Ctrl+Alt+T

  2. Update repository:

    sudo add-apt-repository ppa:openjdk-r/ppa  # only Ubuntu 17.4 and earlier
    sudo apt update
    
  3. Optional: To search available distributions of OpenJDK, use the following command:

    apt search openjdk
    
  4. Install the appropriate version with the following command:

    sudo apt install openjdk-8-jdk
    sudo apt install openjdk-8-source #this is optional, the jdk source code
    
  5. For JAVA_HOME (Environment Variable) type command as shown below, in "Terminal" using your installation path...

    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk
    

    (Note: /usr/lib/jvm/java-8-openjdk is symbolically used here just for demonstration. You should use your path as per your installation.)

  6. For PATH (Environment Variable) type command as shown below, in Terminal:

    export PATH=$PATH:$JAVA_HOME/bin

  7. To check your installation:

    java -version

answered Dec 30, 2020 by Gitika
• 65,950 points

Related Questions In Java

+1 vote
0 answers

How to install java on linux operating system?

I read good info about java here ...READ MORE

May 16, 2019 in Java by Vicky

closed May 16, 2019 by Vardhan 229 views
0 votes
1 answer

How to pad an integer with zeros on the left in Java?

Use java.lang.String.format() method. String.format("%05d", number ...READ MORE

answered May 31, 2018 in Java by Daisy
• 8,110 points
1,249 views
0 votes
1 answer

How to install and configure JDK8 on Windows 10

Hey @Henna, Go to this page  Accept the license ...READ MORE

answered Feb 28, 2019 in Java by Kalgi
403 views
0 votes
1 answer

How to run a Java program from the command line on Windows?

Hello @kartik, In case your Java class is ...READ MORE

answered Apr 9, 2020 in Java by Niroj
• 82,820 points
222 views
0 votes
1 answer
0 votes
1 answer

Serverspec doesn't check package version correctly

Specinfra is escaping the characters in the with_version chain ...READ MORE

answered Aug 2, 2018 in DevOps Tools by Kalgi
• 52,370 points
369 views
0 votes
1 answer

How do I set variable if a specific package version is installed in CFEngine?

Here is what you can do.Just use packagesmatching to ...READ MORE

answered Jul 12, 2018 in Other DevOps Questions by Atul
• 10,240 points
346 views
0 votes
1 answer
0 votes
1 answer

How to install Java 8 on Mac

Oracle has a poor record for making ...READ MORE

answered Dec 23, 2020 in Java by Gitika
• 65,950 points
666 views
+1 vote
13 answers

How to send HTTP POST requests on Java?

With Apache HttpClient In the old days, this Apache ...READ MORE

answered Dec 10, 2020 in Java by Rajiv
• 8,890 points
129,707 views