9

I'm running Rstudio on its own server. Java is installed with good java_home and bin. R is installed. rJava is installed.

Tried to do command: library("rJava") but had issues with libjvm.so, do following Rstudio recommandation I did sudo R CMD javareconf with root.

Here is the output of my javareconf:

Java interpreter : /home/scoremd/jdk1.7.0_03/jre/bin/java
Java version : 1.7.0_03
Java home path : /home/scoremd/jdk1.7.0_03
Java compiler : /home/scoremd/jdk1.7.0_03/bin/javac
Java headers gen.: /home/scoremd/jdk1.7.0_03/bin/javah
Java archive tool: /home/scoremd/jdk1.7.0_03/bin/jar
NOTE: Your JVM has a bogus java.library.path system property!

Trying a heuristic via sun.boot.library.path to find jvm library...
Java library path: $(JAVA_HOME)/jre/lib/amd64:$(JAVA_HOME)/jre/lib/amd64/server
JNI linker flags : -L$(JAVA_HOME)/jre/lib/amd64 -L$(JAVA_HOME)/jre/lib/amd64/server -ljvm
JNI cpp flags : -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/linux

Seems there is issue with finding the java library path... but my java is working fine and R also.

I didn't receive any solution from RStudio support and community (told me to ask in SO ....).

4
  • 2
    The javareconf output above is just fine (it is just telling you that it was working around bugs in your Java) - it found all the paths as you can see. Did you re-install rJava from sources after running javareconf? Also note that for this to work whatever you're running (Rstudio?) must be started with the R script (i.e. if your line doesn't start with R ... it's unlikely to work). If you still have issues, provide details (what exactly are you running and what errors you get). BTW: support for rJava is on the stats-rosuda-devel mailing list. Commented Mar 28, 2012 at 13:03
  • I have the same problem! How did you solve this?
    – while
    Commented Feb 13, 2013 at 13:03
  • 1
    have you tried stackoverflow.com/a/15806471/2161065 ? best regards, Sascha Commented Apr 25, 2013 at 12:33
  • Have you tried installing the rJava package as a root user?
    – Avinash
    Commented Dec 13, 2013 at 7:46

2 Answers 2

2

I have rstudio-server installed on my Centos server. There are a couple of users using rstudio and we decided to upgrade R from 3.6 to 4.0.

After the upgrade :

  • all users were running R 4.0.
  • No user could install rJava using install.package('rJava'). This error always popped up

configure: error: Cannot compile a simple JNI program. See config.log for details. Make sure you have Java Development Kit installed and correctly registered in R. If in doubt, re-run "R CMD javareconf" as root. ERROR: configuration failed for package ‘rJava’

  • Running SUDO R CMD javareconf went smoothly, and also when I opened R as root and went along and tried install.packages('rJava') it installed the package just fine. (unbeknownst to me, root ran R 3.6 and users 4.0, see solution below)
  • However it did not work installing the package for users in R studio server. Always stating the same "try running sudo R CMD javareconf" as if the Java path for the users was wrong.
  • so we tried setting the "JAVA_HOME" variable to the same path that java jdk was installed in (found by searching installed packages in yum). That did not solve it.

my solution I saw that root was running version 3.6 of R while all users ran 4.0. This was because I had installed 4.0 in another directory.. The directory of R 4.0 happens to be found first by the users. However for the root user... it finds the path of R 3.6 first. So I set the path to the 4.0 folder in the $PATH variable of the root user, so that would find version 4.0 before finding R 3.6

  • echo $PATH
  • export PATH="/usr/local/bin:$PATH"
  • echo $PATH

Then I ran R as that user and ran "R CMD javareconf", installed the packages and all users are happy and working again.

(disclaimer, I'm not a experienced linux admin, there may be a better solution for running different R versions)

0

It's been some time since I used rJava, and it was on Windows, but I have some notes which may help you:

  • Make sure that the JRI native library is in a directory listed in java.library.path
    • (also confirmed using Process Explorer that jri.dll is being loaded)
  • The R process loads up jvm.dll when you do library(rJava)

Replace jvm.dll iny my notes above with libjvm.so in your case, and jri.dll with whatever .so file is relevant to you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.