Cannot load rJava because cannot load a shared library

java, path, r

Solution

Following up on some of Dirk's sage advice:

- Your path should probably say `C:\Program Files\Java\jre6\bin\` (remove "client").

- Your path should also have `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.

- Lastly, confirm that Java is accessible by either going to your command prompt and typing `java -version`, or from within R by typing `system("java -version")`.

- If you install the SDK, then you will also want a system variable `JAVA_HOME` which in my case points to `C:\Sun\SDK\`.

Problem

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.logical(now), ...) : unable to load shared library \ 'C:/PROGRA~1/R/R-210~1.1/library/rJava/libs/rJava.dll': LoadLibrary failure: The specified module could not be found. Error : .onLoad failed in 'loadNamespace' for 'rJava' Error: package/namespace load failed for 'rJava' ``` I have tried so many solutions that they are all bamboozeled in my head. At some point I even got ``` > R Console: Rgui.exe - System Error The > program can't start because > MSVCR71.dll is is missing from your > computer. Try reinstalling the program > to fix this problem. ``` I made sure everything I could think of was on the path ``` > C:\Program Files\R\Rtools\bin;C:\Program Files\R\Rtools\perl\bin; C:\Program Files\R\Rtools\MinGW\bin;%SystemRoot%\system32; %SystemRoot%;%SystemRoot%\System32\Wbem; %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\; C:\Program Files\QuickTime\QTSystem\; C:\Program Files\R\R-2.10.1\library\rJava\libs\; C:\Program Files\R;C:\Program Files\Java\jre6\bin\client ``` What should I try next? I am running R version 2.10.1 (2009-12-14) and I have also tried R version 2.10.1 Patched (2010-03-03 r51210). It is on a Windows machine running windows 7 enterprise

Original source