4

I am using rstudio on ubuntu 12.4 server with r 3.1.1. Installed rJava successfully. But not able to load the rjava library. I am using "rstudio" as a user.

Loading required package: rJava
Error : .onLoad failed in loadNamespace() for 'rJava', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/home/rstudio/R/x86_64-pc-linux-gnu-library/3.1/rJava/libs/rJava.so':
  libjvm.so: cannot open shared object file: No such file or directory
Error: package ‘rJava’ could not be loaded

But I could see the file in the mentioned loacation.

Also when I did in Rstudio...

>Sys.getenv("LD_LIBRARY_PATH")

[1] "/usr/lib/R/lib:/lib:/usr/lib/jvm/java-6-openjdk-amd64/jre/lib/amd64/server:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@:@JAVA_LD@"

When I did sudo R CMD javareconf I get following

Java interpreter : /usr/bin/java
Java version     : 1.6.0_32
Java home path   : /usr/lib/jvm/java-6-openjdk-amd64/jre
Java compiler    : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar

trying to compile and link a JNI progam
detected JNI cpp flags    :
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG      -fpic  -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -D_FORTIFY_SOURCE=2 -g  -c conftest.c -o conftest.o
conftest.c:1:17: fatal error: jni.h: No such file or directory
compilation terminated.
make: *** [conftest.o] Error 1
Unable to compile a JNI program


JAVA_HOME        : /usr/lib/jvm/java-6-openjdk-amd64/jre
Java library path:
JNI cpp flags    :
JNI linker flags :
Updating Java configuration in /usr/lib/R
Done.

Can anyone please help to resolve the issue.

Thanks, Amit

5 Answers 5

2

Try sudo apt-get install r-cran-rjava

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for your reply... I already did that ... it is not helping
2

Also you guys should install sudo apt-get install r-cran-rjava and then

R CMD javareconf (as root)

and you are good to go I think...

1 Comment

This was not a solution for me. Success with those commands seems to work for R in the terminal but not RStudio Server.
1

install rJava with unroot user

here is my successfully installed experience:

download the latest jdk and uncompressed, then:

export JAVA_HOME=/public/software/jdk1.8.0_11/
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:/public/software/jdk1.8.0_11/lib/
~/soft/bin/R CMD INSTALL ~/soft/R/R_package_archive/rJava_0.9-6.tar.gz

done!

Comments

1

This worked for me:

Reinstall rJava package

install.packages("rJava")

Comments

0

I was going crazy because I could make rJava work on a terminal, but not on rstudio-server. In the end this worked for me:

sudo systemctl restart rstudio-server
sudo rstudio-server kill-all

It does kill all rstudio server sessions though.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.