27
votes

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.

3
Take a look here maybe. There are some good tips there.David Arenburg
I had check that post before posting the question. I tried everything there. Does not seem to work for me.Aman Mathur
Did you tried sudo R CMD javareconf I had the same problem. rJava trying to check the directories which is not at all there in my system. But after running the above config command, it worked for me.Manoj G
thanks Manoj sudo R CMD javareconf worked for me.gladmax

3 Answers

76
votes
sudo R CMD javareconf

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

2
votes

I have a VM of Ubuntu 14.04 LTS on VirtualBox, and the real path of installation of my java-jdk is the following :

/usr/lib/jvm/java-7-openjdk-amd64

This command worked very fine for my situation. I had this type of error from installation o rJava package on RStudio:

*./configure: line 3736: /usr/lib/jvm/default-java/jre/bin/java: No such file or directory*

First I' have modified the profile in this way : sudo gedit /etc/profile and then added this instructions at the eof:

JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export PATH

After this, from terminal session I've typed the command:

sudo R CMD javareconf

and the package rJava was successfully installed.

Note: You might also have to set the LD_LIBRARY_PATH environment variable, before running sudo R CMD javareconf.

0
votes

Faced same problem in Ubuntu 14.04. This installation guide was helpful for me after going through a straightforward installation. http://www.korecky.org/?p=1254 (Installation of R) and [http://www.korecky.org/?p=847] (Installation of Java)