How can I install rJava for use with 64bit R on a 64 bit Windows computer?

Answer in link resolved my issue.

Before resolution, I tried by adding JAVA_HOME to windows environments. It resolved this error but created another issue. The solution in above link resolves this issue without creating additional issues.


If like me you do not have admin rights to install 64-bit Java, just open 32-bit R and it should work ok on your 64 bit PC as part of the problem seems to be the rJava library function calls embedded Java functions/routines, which may only have being designed for 32-bit interface with Excel/Windows and possibly too large a task at the time to change everything.


The error is telling you that there is no entry in your Registry that tells R where Java is located on your machine. Either your registry is corrupt, but more likely you haven't installed Java. You can install either the Java Runtime Environment or the Java Development Kit.

(You can download Java here.)

If you installed Java, try reinstalling it. This should put the entries back in your Registry.

If that doesn't work, you can start looking at exactly where R is looking for your Registry entries. The function that rJava uses to find Java is in the rJava:::.onLoad function. Within that function there is a subfunction called find.java. I copy the contents here:

    find.java <- function() {
        for (root in c("HLM", "HCU")) for (key in c("Software\\JavaSoft\\Java Runtime Environment", 
            "Software\\JavaSoft\\Java Development Kit")) {
            hive <- try(utils::readRegistry(key, root, 2), 
              silent = TRUE)
            if (!inherits(hive, "try-error")) 
              return(hive)
        }
        hive
    }

Copy and paste this into your R window, and then run it find.java(). rJava is looking for an entry for JavaHome. If that isn't listed, then it is missing from your registry.

You could also manually set the directory of your Java location by setting it before loading the library:

Sys.setenv(JAVA_HOME='C:\\Your\\Java\\Directory')
library(rJava)

Tags:

R

Iplots