Back

Explore Courses Blog Tutorials Interview Questions
0 votes
5 views
in Java by (4k points)

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?

1 Answer

0 votes
by (46k points)

Follow these steps to install open JDK in Ubuntu (Linux):

  • Open Terminal from Application Dash or press Ctrl+Alt+T

First  Update the repository:

sudo add-apt-repository ppa: OpenJDK-r/ppa 

sudo apt update

  • Optional: If you want to seek accessible distributions of OpenJDK, use the following command:

apt search OpenJDK

  • Install the relevant version with the command below:

sudo apt install OpenJDK-8-JDK

sudo apt install OpenJDK-8-source #this is optional, the JDK source code

  • For JAVA_HOME (Environment Variable) write command as given 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 practiced here just for presentation. You can use your path as per your installation.)

  • For PATH (Environment Variable) type command as explained below, in Terminal:

export PATH=$PATH:$JAVA_HOME/bin

  • To verify your installation:

java -version

Related questions

0 votes
1 answer
asked Feb 6, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
asked Mar 24, 2021 in Java by dante07 (13.1k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...