How to set the JAVA_HOME path in Debian 10
In this article, we will learn how to install Java JDK on the Debian operating system and then set the JAVA_HOME and PATH variables.
In this article, we will learn how to install Java JDK on the Debian operating system and then set the JAVA_HOME and PATH variables.
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.
Install OpenJDK on DebianThe 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.
The value is stored in the JAVA_HOME variableAdd 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
Check the JAVA setting Now, you can easily develop and run JAVA applications on your system.
You should read it
- How to Set Java Home
- How to install Debian on a computer
- How to upgrade Debian
- How to Install Gradle on Debian 10
- Notable changes and additions in Debian 11 'Bullseye'
- Do not destroy the Debian system!
- Debian 10 Buster, New features in Debian 10 Buster
- How to Restart Debian Using the Command Line
- What is Windows PATH?
- 9 best Debian-based Linux distributions
- How to Install and Use Ansible on Debian 10
- How to Install Debian
Maybe you are interested
Why do most rockets launch near the equator? How to create permanent tab groups in Google Chrome 9 practical applications of ChatGPT in programming Should iPhone 11, 11 Pro users upgrade to iPhone 13? Tips to Make perform Laptop keyboard quick fix How to increase HDD capacity of VirtualBox with Clonezilla