How to Install Java on Ubuntu

1. Download the appropriate version of Java.

2. Navigate to the directory containing the Java package, right-click, and select “Open in Terminal.”

3. Run the following command:

sudo dpkg -i <jdk-.......>

After typing the first few letters of the package name, you can use the Tab key to autocomplete the rest.

4. To verify if Java is installed, run:

java --version

Set Java Environment

1. To view the directory path where Java is installed, use the following command:

sudo update-alternatives --config java

2. Set the JAVA_HOME path using either Vim or Nano:

sudo vim /etc/environment // After typing "env", press Tab to autocomplete

Then add the following line:

JAVA_HOME=”the_path” and save the file.

3. Run:

source /etc/environment

4. Finally, to confirm that everything was set up correctly, run the following command. You should see the Java path:



Java Environment on Ubuntu

Leave a Reply