I am using SSH Client. I have run the environment variable still
echo $JAVA_HOME is not returning anything. I want to find the exact location where the java is installed in unix. is there any other command which can help me with this ?
The which
command gives you the path to the java
binary:
which java
But if it is only a symlink (e.g. used by alternatives
) this will not get your the real path to the binary. You can either list where the symlink points to with with ls -l
:
ls -l `which java`
which for me outputs
/usr/bin/java -> /etc/alternatives/java
and then follow the symlinks until you are at the source. Alternatively, if available on your system, use the readlink
command in combination with -f
which follows symlinks for you:
readlink -f `which java`
Edit: Ankit wrote in the comments that readlink
is not a standard UNIX command and -f
also does not seem to work on a mac, so this may not be an option for you, although this page describes how to get greadlink
to get this functionality on a mac via brew
:
brew install coreutils greadlink -f
which java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With