Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

How to Set the JAVA_HOME Path in Debian 10

Learn how to Set the JAVA_HOME Path in Debian with clear steps, useful examples, and practical tips. Complete the task correctly and avoid common mistakes.

Table of Contents

This updated guide explains how to Set the JAVA_HOME Path in Debian 10 through clear steps, practical examples, and important checks that help prevent common errors.

Note : The commands and procedures mentioned in this article are done on Debian 10. The same procedure can be applied in other Linux distributions and on older versions of Debian.

Let's start by installing JDK first.

Install OpenJDK on Debian

First, launch Terminal in the operating system. Go to the Activities tab in the top left corner of the desktop. Then search for the Terminal application by typing the relevant keyword into the search bar. From the result, click the Terminal icon to open.

Now in Terminal, run this command with sudo to install Open JDK.

$ sudo apt install openjdk-8-jdk

When prompted for a password, enter the sudo password.

Set the JAVA_HOME Path in Debian 10 — Install OpenJDK on Debian screenshot 1 Install OpenJDK on Debian

The system may require confirmation by providing the Y / N option. Press Y and Enter to confirm, then the Open JDK installation process will be started on the system.

If you receive this error during installation: 'Package OpenJDK has no installation candidate' , follow the steps below:

1. Edit the sources. list file using the following command in Terminal:

$ sudo nano /etc/apt/sources.list

2. Add the following archive to your sources. list file .

deb http://ftp.de.debian.org/debian sid main

Then press Ctrl + O and Ctrl + X to save and exit the file.

3. Update the repository index with the following command:

$ sudo apt update

4. Then run the installation command as follows:

$ sudo apt install openjdk-8-jdk

Set the Path for JAVA_HOME

Find the path to install OpenJDK on the system. Usually, it is usr / lib / jvm / java-8-openjdk-amd64 /. To set the JAVA_HOME environment path, enter the following command in Terminal:

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

You have now set the JAVA_HOME path and can verify it by running the following command in Terminal:

$ echo $JAVA_HOME

In the output, you will see the value stored in the JAVA_HOME variable as shown in the following screenshot.

Set the JAVA_HOME Path in Debian 10 — Set the Path for JAVA_HOME screenshot 2 The value is stored in the JAVA_HOME variable

Add the JAVA Bin Directory to the PATH Variable

Similar to the JAVA_HOME path, you will now add the $ PATH variable. The $ PATH variable points to the bin directory in the JDK installation directory. Since the JDK directory location has been set using the JAVA_HOME variable, now we only need to use the JAVA_HOME attribute to set the bin directory location.

Enter this command in Terminal to add a Java bin directory to the PATH variable:

$ export PATH=$PATH:$JAVA_HOME/bin

The Java bin directory will be added to the existing PATH variable. To verify it, run the following command in Terminal:

$ echo $PATH

Check the JAVA Setting

Now that we've installed OpenJDK and set the variables JAVA_HOME and PATH, it's time to verify the installation. In Terminal, run the following command to do so:

$ java -version
Set the JAVA_HOME Path in Debian 10 — Check the JAVA Setting screenshot 3 Check the JAVA setting

Now, you can easily develop and run JAVA applications on your system.

FAQ

What is the easiest way to Set the JAVA_HOME Path in Debian 10?

Start with the requirements in this guide, then follow each step in order. Check the result after every major change so problems are easier to identify.

Can beginners follow these instructions?

Yes. The process is organized into practical steps, and you can repeat any step before moving forward.

What should I check if the method does not work?

Confirm your software or device version, permissions, settings, file format, and internet connection when the task depends on online services.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.