JAVA_HOME directory in Linux

Progress Programmer picture Progress Programmer · Jul 13, 2009 · Viewed 269.6k times · Source

Is there any linux command I could use to find out JAVA_HOME directory? I've tried print out the environment variables ("env") but I can't find the directory.

Answer

jsdevel picture jsdevel · Dec 18, 2013

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