Search code examples
javarjvmrjava

library(rJava) does not load after installing package


I have been reading up on examples and cannot figure out the solution. I also had IT come by and they can't figure out why it isn't working also.

I am trying to use the 'rJava' package from R.

I uninstalled RStudio and R to get the latest versions.

Here is what I did:

install.packages('rJava')
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/rJava_0.9-9.zip'
Content type 'application/zip' length 720033 bytes (703 KB)
downloaded 703 KB

package ‘rJava’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
    C:\Temp\RtmpSyCpeu\downloaded_packages

Then when I run below, this is what shows up:

library(rJava)

enter image description here

This same error message happens after I uninstalled RStudio and R.

When I click ok, below is the error that comes up.

Error: package or namespace load failed for ‘rJava’:
 .onLoad failed in loadNamespace() for 'rJava', details:
  call: inDL(x, as.logical(local), as.logical(now), ...)
  error: unable to load shared object 'C:/Users/nicknaue/Documents/R/R-
3.4.3/library/rJava/libs/x64/rJava.dll':
  LoadLibrary failure:  The specified module could not be found.

To try and solve for this, we downloaded the latest Java and also got a file from another program with the same name: jvm.dll and put it in the same file path. No luck also.

Has anyone come across this issue before?

Also, something weird, I have another computer where I tried this on and no errors came up.

I know there have been posts on this but I feel like I have tried everything at this point.


Solution

  • Figured out the answer from this link: Unable to load rJava on R

    The issue was that I had 64-bit R and 32 bit Java. The two were not compatible before. You need 64 bit Java in order to run rJava if you have 64 bit R.