Languages
[Edit]
EN

Linux / Ubuntu - set system JAVA_HOME env variable

4 points
Created by:
ParaEagle
724

In this short article we woukld like to show how to set JAVA_HOME environment variable in Ubutnu 18.04.

Quick solution (create /etc/profile.d/jdk file with following content):

Where: /usr/lib/jvm/java-14-oracle should be changed to Java instalation directory path.

Detailed description

Edit

The approach presented in article should be working on Debian or latest Ubuntu too.

Hint: for java installed from package name ended with *.-set-default postfix, JAVA_HOME should be set automatically, e.g.

sudo apt-get install oracle-java14-set-default

Simple steps:

1. find java directory path:

Output:

Note: we want to use: /usr/lib/jvm/java-14-oracle (it is line 8).

2. add /etc/profile.d/jdk file with following content:

Note: you can add it on the beginning of /etc/profile too - this approach is not recommended because of messing in scripts politics.

3. rebot operating system with:

4. test JAVA_HOME variable with:

Output:

 

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Linux

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join