BLOG

Setting JAVA_HOME

Christian Fröhlingsdorf
April 20, 2021
Table of Contents:

Java remains exceedingly popular. To be executed, Java software requires a runtime environment. Most scripts and programs find this environment using the JAVA_HOME environment variable, assuming it has been set and points to the correct file path.

A prerequisite for this tutorial is that you have already installed Java (SDK or RDK).

On Linux or Mac devices, you can set your JAVA_HOME variable as follows:

Firstly, you can check if the variable has already been set by opening the command line and using the following command: echo $JAVA_HOME.

If a file path is returned as a result, the variable has already been set. If you cannot find a path or if the path is incorrect, you can now set or modify it.

If you don't know your Java installation path, you can possibly find the installation path with the command ls -l $(which java).

Open nano ~/.bashrc or nano ~/.bash_profile or your favorite shell eg. nano ~/.zshrc. Add the line export JAVA_HOME=/usr/java/jre1.8.0_04, where /usr/java/jre1.8.0_04 should be replaced by your path if necessary. Save the file.

Check the path again:

Load source ~/.bashrc or source ~/.bash_profile or your favorite shell, e.g., source ~/.zshrc. Execute echo $JAVA_HOME again, and you should see your changed path.

Other blog posts you might like:

Ready to elevate your incident management?
Start for free
Our Cookie Policy
We use cookies to improve your experience, analyze site traffic and for marketing. Learn more in our Privacy Policy.
Open Preferences
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.