I have been struggling to load the rJava package in R.
I get the following messages
> library(rJava)
Error in inDL(x, as.logical(local), as.logic
After editing your post for readability / formatting it seems that you have no Java system in your path. I don't use the OS you're trying to use this on, but on mine rJava
only works if I also install a Java Run-Time Environment or, better still, a Java SDK.
Note that the package clearly lists
SystemRequirements: java
and that the rJava site clearly states the following
Installation
First, make sure you have JDK 1.4 or higher installed (some platforms require hgher version see R Wiki). On unix systems make sure that R was configured with Java support. If not, you can re-configure R by using R CMD javareconf (you may have to prepend sudo or run it as root depending on your installation - see R-ext manual A.2.2 for details). On Windows Java is detected at run-time from the registry.
rJava can be installed as any other R package from CRAN using install.packages('rJava'). See the files section in the left menu for development versions.
JRI is only compiled if supported, i.e. if R was configured as a framework or with --enable-R-shlib.
so I think we have a few smoking guns pointing the same way.
If you have read this threat and neither of the suggestions above has worked so far, then it might be worth trying one further:
Java(TM) SE Runtime Environment (build 1.6.0_23-b05), Java HotSpot(TM) 64-Bit Server VM (build 19.0-b09, mixed mode)
JAVA_HOME=C:\Program Files\Java\jre6\bin\
Path= ...;C:\Program Files\Java\jre6\bin\server\;C:\Program Files\R\R-2.12.1\bin\x64\
The thing that finally solved my problem was to explicitly add \server\
to the PATH variable.
Following up on some of Dirk's sage advice:
C:\Program Files\Java\jre6\bin\
(remove "client"). C:\Program Files\R\R-2.10.1\bin\
. You don't need that explicit reference to the rJava libs. I would also then remove C:\Program Files\R
from the path.java -version
, or from within R by typing system("java -version")
.JAVA_HOME
which in my case points to C:\Sun\SDK\
.System information: R version 3.0.1 (2013-05-16) Platform: x86_64-w64-mingw32/x64 (64-bit)
I encountered this same problem. I was able to solve the issue with one line of code into the command window obtained from this website.
Sys.setenv(JAVA_HOME='C:\Program Files\Java\jre7')
Note that I used this particular line because I was on a 64 bit system. See website for 32-bit example.
For what it's worth, putting C:\Program Files\Java\jre6\bin\[server]
in my PATH
worked for me. It seems the rJava module could jot find jvm.dll
there.
Here are the versions of R and Java that I'm using (on 64-bit Windows 7).
Java:
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03, mixed mode)
R:
R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-mingw32/x64 (64-bit)
I had a similar error and had to do an additional fix: Setting the R path explicitly to ...bin\x64, and also being consistent in using x64 Java and R.