When run from Rstudio console, Sys.getenv("JAVA_HOME") produces "/usr/lib/jvm/java-8-oracle". However, the same command yields "/usr/lib/jvm/jdk-11.0.8" when run from Rstudio terminal.
whereis java -b shows that both the java-8 and jdk-11 are on the path variable as shown below,
java: /usr/bin/java /etc/java /usr/share/java /opt/jdk1.8.0_73/bin/java /usr/lib/jvm/java-8-oracle/bin/java /usr/lib/jvm/java-8-oracle/jre/bin/java /usr/lib/jvm/jdk-11.0.8/bin/java
update-alternatives --config java shows that the selected default java is jdk11,
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
----------------------------------------------------------------------------
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 auto mode
1 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 manual mode
* 2 /usr/lib/jvm/jdk-11.0.8/bin/java 1 manual mode
can anyone kindly explain what could be the reason for getting very different outputs?