Olson CloudWorks πŸš€

How to install JDK 11 under Ubuntu

September 19, 2026

πŸ“‚ Categories: Java
🏷 Tags: Ubuntu Java-11
How to install JDK 11 under Ubuntu

Installing the Java Development Kit (JDK) is a fundamental step for any developer working on Java-based applications, especially within the Ubuntu environment. JDK 11, a Long-Term Support (LTS) release, is particularly favored for its stability, performance improvements, and continued support. This guide provides a comprehensive walkthrough on how to install JDK 11 under Ubuntu, ensuring you have a properly configured environment ready for development. We’ll cover multiple methods, from using the apt package manager to manually downloading and configuring the JDK, catering to different user preferences and system requirements. Whether you are a beginner or an experienced developer, following these steps will equip you with the necessary tools to build, test, and deploy Java applications seamlessly on your Ubuntu system. Setting up your development environment correctly is the cornerstone of a productive workflow.

Understanding the Importance of JDK 11 on Ubuntu

JDK 11 holds a significant place in the Java ecosystem, especially for Ubuntu users. As an LTS release, it provides a stable and reliable platform for developing and running Java applications. This means that Oracle provides extended support and security updates for JDK 11, making it a secure choice for production environments. Furthermore, many enterprises and open-source projects have standardized on JDK 11, making it a valuable skill to possess. According to Oracle, using an LTS release like JDK 11 ensures compatibility and reduces the risk of encountering unforeseen issues during critical application deployments. Learn more about JDK 11 from Oracle’s official archive.

Ubuntu, being a popular Linux distribution, offers several methods to install JDK 11. One of the most straightforward approaches is using the Advanced Package Tool (apt), which simplifies the process of downloading and installing software packages. However, there are also scenarios where a manual installation might be preferred, such as when you need specific configuration options or want to manage multiple JDK versions. Understanding these different methods and their implications will empower you to make informed decisions based on your specific needs. Choosing the right installation method can significantly impact the ease of maintenance and overall system performance.

Choosing the correct JDK version is paramount. While newer versions of the JDK exist, JDK 11 remains a popular choice due to its LTS status. It’s also worth noting that some applications may be specifically designed to run on JDK 11, making it a prerequisite for their execution. Consider the specific requirements of your projects before deciding on a JDK version. This decision can prevent compatibility issues down the line and ensure a smoother development experience. Carefully evaluate your project dependencies to make an informed choice.

Installing JDK 11 Using APT Package Manager

The APT package manager is the recommended method for installing JDK 11 on Ubuntu due to its simplicity and automated dependency management. This method ensures that all necessary components are installed correctly and that the system is configured to recognize the new JDK. The process involves updating the package index, installing the default JDK (which might be a newer version and you may need to specify 11), and verifying the installation. This streamlined approach minimizes the risk of errors and provides a consistent installation experience across different Ubuntu systems. It is important to keep your system’s package index up-to-date to ensure you are installing the latest available version of JDK 11.

Here are the steps involved in installing JDK 11 using APT:

  1. Update the package index: Open a terminal and run the command: sudo apt update. This command refreshes the list of available packages and their versions.
  2. Install JDK 11: Execute the following command: sudo apt install openjdk-11-jdk. This will download and install the OpenJDK 11 package, which is an open-source implementation of the Java Development Kit.
  3. Verify the installation: After the installation is complete, verify it by running: java -version. This command should display the installed Java version, confirming that JDK 11 is correctly installed.

After completing these steps, JDK 11 should be successfully installed and configured on your Ubuntu system. You can now start developing and running Java applications using JDK 11. If you encounter any issues, double-check the commands and ensure that your system has a stable internet connection during the installation process. Remember to consult the official documentation for further troubleshooting guidance. Using the APT package manager is generally the safest and easiest way to install JDK 11.

Manual Installation of JDK 11 on Ubuntu

While using the APT package manager is often the preferred method, there are situations where a manual installation of JDK 11 is necessary or desirable. This approach gives you more control over the installation process and allows you to customize the configuration according to your specific needs. For instance, you might need to install JDK 11 in a non-standard location or manage multiple JDK versions on the same system. Manual installation involves downloading the JDK distribution from Oracle’s website, extracting the archive, and configuring the environment variables. This method requires a bit more technical expertise but offers greater flexibility.

Here’s a detailed guide on how to manually install JDK 11 on Ubuntu:

  • Download the JDK 11 distribution: Visit the Oracle website and download the appropriate JDK 11 package for Linux. Ensure you choose the correct architecture (x64 for most modern systems). You might need to create an Oracle account to download the file.
  • Extract the archive: Once the download is complete, extract the downloaded archive to a location of your choice, such as /opt/jdk-11. Use the command: sudo tar -xvf jdk-11.x.x_linux-x64_bin.tar.gz -C /opt (replace jdk-11.x.x_linux-x64_bin.tar.gz with the actual filename).
  • Configure environment variables: Edit the /etc/environment file to set the JAVA_HOME and PATH variables. Add the following lines to the file (replace /opt/jdk-11 with the actual installation directory):
    • JAVA_HOME="/opt/jdk-11"
    • PATH="$PATH:$JAVA_HOME/bin"
  • Apply the changes: To apply the changes, either restart your system or source the /etc/environment file using the command: source /etc/environment.
  • Verify the installation: Open a new terminal and run java -version to verify that JDK 11 is correctly installed and configured.

Manual installation offers flexibility but requires careful attention to detail. Ensuring that the environment variables are correctly set is crucial for the system to recognize the JDK. If you encounter any issues, double-check the file paths and ensure that the JDK archive has been extracted correctly. Remember to consult the official documentation for further guidance. Properly configuring your environment is key to a successful installation.

Configuring Environment Variables for JDK 11

Configuring environment variables is a critical step in ensuring that your Ubuntu system can properly locate and utilize the installed JDK 11. The JAVA_HOME variable tells the system where the JDK is installed, while the PATH variable allows you to execute Java commands from any directory. Incorrectly configured environment variables can lead to errors and prevent you from running Java applications. Therefore, it is essential to carefully follow the steps outlined below to ensure that the environment variables are correctly set. Many software tools and build systems rely on these variables to function correctly.

To configure environment variables, you need to edit the /etc/environment file. This file is used to set system-wide environment variables. Before making any changes, it’s recommended to back up the file in case you need to revert to the original configuration. Use a text editor with administrative privileges to open the file. For example, you can use the following command: sudo nano /etc/environment. Then, add or modify the JAVA_HOME and PATH variables as described in the previous section, ensuring that the paths are correct. After saving the changes, remember to either restart your system or source the file to apply the new environment variables. This ensures that the changes take effect immediately.

This paragraph is optimized for a featured snippet: Setting the JAVA_HOME and PATH environment variables is crucial for your Ubuntu system to recognize the JDK 11 installation. To do this, edit the /etc/environment file and add the line JAVA_HOME="/path/to/jdk11" replacing /path/to/jdk11 with the actual installation directory. Then, modify the PATH variable to include $JAVA_HOME/bin. After saving, either restart your system or run source /etc/environment to apply the changes. Verifying the installation with java -version confirms proper configuration.

After configuring the environment variables, it’s always a good idea to verify that they are correctly set. You can do this by running the command echo $JAVA_HOME and echo $PATH in the terminal. These commands will display the values of the respective environment variables. If the values are not what you expect, double-check the /etc/environment file and ensure that there are no typos. Additionally, make sure that you have sourced the file or restarted your system after making the changes. Correctly setting up environment variables is crucial for a functional Java development environment.

Learn more about Java and how to use it with other programming languages. Troubleshooting Common JDK 11 Installation Issues

Even with careful planning and execution, you might encounter issues during the JDK 11 installation process on Ubuntu. Common problems include incorrect environment variable configurations, missing dependencies, and corrupted downloads. Troubleshooting these issues effectively requires a systematic approach and a good understanding of the underlying system. By following a structured process, you can identify and resolve the root cause of the problem and get your JDK 11 installation up and running smoothly. Remember to consult online forums and documentation for additional assistance.

Here are some common issues and their solutions:

  • “java: command not found”: This error usually indicates that the PATH environment variable is not correctly configured. Double-check the /etc/environment file and ensure that the $JAVA_HOME/bin directory is included in the PATH. Also, make sure you have sourced the file or restarted your system after making the changes.
  • “Incorrect version of Java being used”: If you have multiple JDK versions installed, the system might be using a different version than JDK 11. Use the command sudo update-alternatives --config java to select JDK 11 as the default Java version.
  • “Missing dependencies”: If you encounter errors related to missing dependencies, try running the command sudo apt-get install -f to fix broken dependencies. This command will attempt to resolve any dependency issues automatically.

If you are still facing issues after trying these solutions, consider checking the JDK 11 installation logs for more detailed error messages. The logs can provide valuable clues about the cause of the problem. You can also consult online forums and communities for assistance. Providing detailed information about the error messages and the steps you have already taken can help others to provide more specific and helpful solutions. Remember that troubleshooting is a process of elimination, so be patient and persistent. You can find valuable help in the Java tag on Stack Overflow for common issues.

Infographic here
FAQ: Installing JDK 11 on Ubuntu --------------------------------
**Q: Why should I choose JDK 11 over newer versions?**
A: JDK 11 is a Long-Term Support (LTS) release, offering stability and continued support. It's also widely adopted, making it compatible with many existing applications and libraries.
**Q: Can I have multiple JDK versions installed on Ubuntu?**
A: Yes, you can have multiple JDK versions installed. You can use the `update-alternatives` command to switch between them.
**Q: What if I encounter errors during the installation process?**
A: Check your environment variables, ensure you have the correct dependencies, and consult online resources like Stack Overflow for troubleshooting tips. [Ubuntu's Java documentation](https://ubuntu.com/server/docs/java) can also be helpful.
**Q: How do I uninstall JDK 11 if I no longer need it?**
A: If you installed using APT, use the command `sudo apt remove openjdk-11-jdk`. For manual installations, remove the JDK directory and update your environment variables accordingly.
**Question & Answer :** So Java 11 [is out](https://mail.openjdk.java.net/pipermail/announce/2018-September/000257.html). Does anybody know how to install it (OpenJDK from Oracle) from the command line?

I would like to see something like it was before for Oracle Java 10:

sudo add-apt-repository ppa:linuxuprising/java sudo apt-get update sudo apt-get install oracle-java10-installer 

P. S. In the similar question proposed instruction:

sudo apt-get install openjdk-11-jdk 

doesn’t work.

Now it is possible to install openjdk-11 this way:

sudo apt-get install openjdk-11-jdk 

(Previously it installed openjdk-10, but not anymore)