JAVA_HOME directory in Linux
On Linux you can run $(dirname $(dirname $(readlink -f $(which javac))))
On Mac you can run $(dirname $(readlink $(which javac)))/java_home
I'm not sure about windows but I imagine where javac
would get you pretty close
echo $JAVA_HOME
will print the value if it's set. However, if you didn't set it manually in your startup scripts, it probably isn't set.
If you try which java
and it doesn't find anything, Java may not be installed on your machine, or at least isn't in your path. Depending on which Linux distribution you have and whether or not you have root access, you can go to http://www.java.com to download the version you need. Then, you can set JAVA_HOME to point to this directory. Remember, that this is just a convention and shouldn't be used to determine if java is installed or not.