Referring to Ask Ubuntu question How to set JAVA_HOME for OpenJDK?,

How to install Open JDK (Java developement kit) in Ubuntu (Linux)?

  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 demostration. 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

Answer from Dhaval Shah on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › java › download-and-install-jdk-on-windows-mac-and-linux
Download and Install JDK on Windows, Mac and Linux - GeeksforGeeks
April 4, 2026 - C:\Program Files\Java\jdk-{YOUR_JDK_VERSION}. Click on OK => OK => OK. ... Follow the steps below to install the Java software Development Kit on a Linux environment. These instructions are applicable to various Linux distributions such as Ubuntu, ...
🌐
OpenJDK
openjdk.org › install
OpenJDK: Download and install
Oracle's OpenJDK JDK binaries for Windows, macOS, and Linux are available on release-specific pages of jdk.java.net as .tar.gz or .zip archives. As an example, the archives for JDK 13 may be found on jdk.java.net/13 and may be extracted on the command line using ... The openjdk-8-jre package contains just the Java Runtime Environment. If you want to develop Java programs then please install the openjdk-8-jdk package.
🌐
Oracle
docs.oracle.com › en › java › javase › 22 › install › installation-jdk-linux-platforms.html
3 Installation of the JDK on Linux Platforms
March 14, 2024 - The following table lists the differences: Table 3-1 Difference between Generic Linux and OL platforms ... Access Java SE Downloads page and click Accept License Agreement. Under the Download menu, click the Download link corresponding your requirement. The following table lists the options ...
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-jdk-in-linux
How to Install JDK in Linux? - GeeksforGeeks
July 23, 2025 - Here we are going to install JDK in the Debian-based Ubuntu operating system. Step 1: Open your browser and navigate to this link. Step 2: Scroll down and click on the JDK download link.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › install › linux_jdk.html
6 JDK Installation for Linux Platforms
April 21, 2026 - To install the JDK on an RPM-based Linux platform: ... For aarch64 (64-bit ARM) systems: jdk-8uversion-linux-aarch64.rpm. For example, jdk-8u381-linux-aarch64.rpm · For 32-bit systems: jdk-8uversion-linux-i586.rpm. For example, jdk-8u381-linux-i586.rpm · Before you download a file, you must accept the license agreement.
🌐
Oracle
java.com › en › download › help › linux_x64_install.html
Linux 64-bit installation instructions for Java
This procedure installs the Java Runtime Environment (JRE) for 64-bit Linux, using an archive binary file (.tar.gz). Go to http://java.com and click on the Download button.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-in-ubuntu
How to Install Java in Ubuntu – JDK Linux Tutorial
August 11, 2024 - Use the sudo apt install /home/fahim/Downloads/jdk_filename.deb command to start the installation. For me, the entire command is sudo apt install /home/fahim/Downloads/jdk-20_linux-x64_bin.deb.
Find elsewhere
Top answer
1 of 4
11

You can install and stay up to date with the latest Oracle Java 7 and all you have to do is manually add the PPA repository to the Software Sources.

From http://www.webupd8.org/2012/06/how-to-install-oracle-java-7-in-debian.html:

su -
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a     /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer
exit

For Ubuntu, http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html. With this, I've managed to installed JDK on my ubuntu server.

2 of 4
4

Step 1: Open Applicaction>> Accessories>> Terminal

Step 2: Type commandline as below...

  sudo apt-get install openjdk-6-jdk

Step 3: Type commandline as below...

  apt-cache search jdk

(Note: openjdk-6-jdk is symbolically used here you can choose jdk version as per your requirment.)

How to set "Environment Variables" for "Open jdk" in Ubuntu(Linux)?

Step 4: For "JAVA_HOME" (Environment Variable) type command as shown below, in "Terminal" using your installation path...

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

(Note: "/usr/lib/jvm/java-6-openjdk" is symbolically used here just for demostration you should use your path as per your installation.)

Step 5: For "PATH" (Environment Variable) type command as shown below, in "Terminal" using your installation path...

  export PATH=/usr/lib/jvm/java-6-openjdk/bin

(Note: "/usr/lib/jvm/java-6-openjdk" is symbolically used here just for demostration you should use your path as per your installation.)

Step 6: Check for "open jdk" installation, just type command in "Terminal" as shown below java

🌐
Oracle
docs.oracle.com › javase › 10 › install › installation-jdk-and-jre-linux-platforms.htm
5 Installation of the JDK and JRE on Linux Platforms
To install the 64-bit JDK on an RPM-based Linux platform: Download the file, jdk-10.interim.update.patch_linux-x64_bin.rpm.
🌐
Cleverence
cleverence.com › articles › oracle-documentation › installation-of-the-jdk-on-linux-platforms-java-4821
Install JDK on Linux: Step-by-Step Guide for Ubuntu, RHEL, SUSE and More
February 4, 2026 - By the end of this tutorial, you will be able to install the JDK on major Linux families (Debian/Ubuntu, RHEL/CentOS/Fedora, SUSE), verify the installation, set up environment variables for shells and services, and switch between multiple Java versions using update-alternatives or a version manager.
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-openjdk-in-linux
How to Install OpenJDK in Linux - GeeksforGeeks
May 7, 2026 - All the steps are performed here in this guide on Ubuntu Linux distribution. Before installing any software, update your system packages. ... This ensures your system has the latest package information and updates installed. ... Note: After this command you need to enter you password. This will display a list of available OpenJDK versions. As of now, the latest stable version is OpenJDK 21. ... This command installs the OpenJDK Development Kit (JDK), which includes the Java Runtime Environment (JRE) and development tools like the javac compiler.
🌐
Oracle
docs.oracle.com › en › industries › hospitality › enterprise-integrations › gaming-integration › 24.1 › gamig › t_download_jdk17_for_linux.htm
Download JDK17 for Linux
April 22, 2024 - Select JDK17 and then select the Linux tab. Click the x64 RPM Package link to download jdk-17_linux-x64_bin.rpm.
🌐
Opensource.com
opensource.com › article › 19 › 11 › install-java-linux
How to install Java on Linux | Opensource.com
Java is now installed. There are probably many many Java-related packages in your repository. Search on OpenJDK and look for either the most recent JRE or JVM if you're a user and for the most recent JDK if you're a developer. If you can't find a JRE or JDK in your repository, or the ones you find don't fit your needs, you can download open source Java packages from the internet.
🌐
GitHub
gist.github.com › filipelenfers › ef3f593deb0751944bb54b744bcac074
Install JDK from tar.gz Ubuntu · GitHub
download open jdk from https://www.openlogic.com/openjdk-downloads?field_java_parent_version_target_id=416&field_operating_system_target_id=426&field_architecture_target_id=391&field_java_package_target_id=396 ... cd /opt/ && \ tar xzf ...
🌐
The Knowledge Academy
theknowledgeacademy.com › blog › install-java-linux
How to Install Java on Linux: Step By Step Installation Guide
April 23, 2026 - Step 1: Begin by installing JDK on Linux using the command sudo apt install default-jdk. This command will download and install the default version of JRE available in the repository of your Linux Operating System.
🌐
Fabric Documentation
docs.fabricmc.net › players › installing-java › linux
Installing Java on Linux | Fabric Documentation
April 2, 2026 - If you plan to develop mods, you'll need the JDK instead: sh · sudo dnf install java-25-openjdk-devel · 1 · If your distribution isn't listed above, you can download the latest JRE from Adoptium · You should refer to an alternative guide ...