Error of java path on loading rJava package

Aman Mathur picture Aman Mathur · Jun 1, 2015 · Viewed 16.6k times · Source

I am trying to load 'rJava' package in my Unix machine. Before loading I have set the path using

Sys.setenv("JAVA_HOME= myfilepath") 

in my R script.

Despite this I am getting the following error (Below is the part of the error):

checking Java support in R... present:
interpreter : '/usr/lib/jvm/jre/bin/java'
archiver    : '/usr/lib/jvm/jre/../bin/jar'
compiler    : '/usr/lib/jvm/jre/../bin/javac'
header prep.: '/usr/lib/jvm/jre/../bin/javah'
cpp flags   : '-I/usr/lib/jvm/java/include I/usr/lib/jvm/java/include/linux'
java libs   : '-L/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/lib/amd64/server -ljvm'
checking whether Java run-time works... ./configure: line 3729: /usr/lib/jvm/jre/bin/java: No such file or directory
no configure: error: Java interpreter '/usr/lib/jvm/jre/bin/java' does not work

As you can see the error shows that /usr/lib/jvm/jre/bin/java: No such file or directory. But I have not set this as myfilepath. How do I prevent the installer from looking at this path?

Kindly help.

Answer

Sushant Gupta picture Sushant Gupta · Aug 21, 2016
sudo R CMD javareconf

This works perfectly. Keeping this here if someone reads this in future.