I'm running R 3.0.2 on Ubuntu 14.04.1. I've installed the rJava package, but I can only get it to work in R/RStudio if I launch it with sudo. If I click on the application launcher, or just enter R in the command line, I get the following error when loading the rJava library:
> library(rJava)
Error : .onLoad failed in loadNamespace() for 'rJava', details:
call: dyn.load(file, DLLpath = DLLpath, ...)
error: unable to load shared object '/usr/lib/R/site-library/rJava/libs/rJava.so':
libjvm.so: cannot open shared object file: No such file or director
Error: package or namespace load failed for ‘rJava’
However, if I type 'sudo rstudio' or 'sudo R' in a terminal, rJava loads without a problem. Does anybody know what I'm doing wrong?
Possibly related issue: I installed rJava by entering
sudo apt-get install r-cran-rjava
at the command prompt; installing the normal way:
apt-get install r-cran-rjava
did not work for me, and neither did installing from within R (without launching it using sudo). When I tried to install this way, I ran into the same problem as addressed in this question.
The file /usr/lib/R/site-library/rJava/libs/rJava.so
is probably not readable by any user other than root. You can check that with:
ls -l /usr/lib/R/site-library/rJava/libs/rJava.so
If the output is rw-------
or rw-rw----
then simple users won't be able to read it. You can correct that with the chmod
command:
chmod -R a+rX /usr/lib/R/site-library/rJava/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With