Reading time: < 1 minute
Today I’m going to show you how to create the JAVA_HOME environment variable in Linux or Ubuntu:
The first thing you need to do is to have JDK installed.
Then, execute this command to find out where it is installed:
jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));'
Once located, add the environment variable using the export command:
export JAVA_HOME="$(jrunscript -e 'java.lang.System.out.println(java.lang.System.getProperty("java.home"));')"
And you can verify that it has been created:
echo $JAVA_HOME