I have script to get the java path from this command: readlink -f $(which java)
.
But it displays wrong path : /usr/local/bin/javavm
While I need to have this path : /usr/local/openjdk8/bin/java
I tried to give export command: export JAVA_HOME=/usr/local/openjdk8/, but the issue remains same.
I tried this post as well : https://stackoverflow.com/a/39691105/10220825
and this post : https://askubuntu.com/a/554052/905016
I also tried : sudo ln -s /usr/local/bin/javavm /usr/local/openjdk8/bin/java
but it results, ln: /usr/local/openjdk8/bin/java: File exists
and issue remain same.
I dont want to hardcode it, neither I want to use other command like which java
or echo $JAVA_HOME
as the script is getting the expected result in Linux but only problems with FreeBSD machine.
I also dont want to apply any parsing like awk
or sed
from the output of readlink -f $(which java)
.
Can someone suggest me how to change the value from readlink -f $(which java)
.