7

When loading rJava I get the following error message:

Error in get(Info[i, 1], envir = env) : lazy-load database 'C:/Users/dell_x/Documents/R/win-library/3.3/rJava/R/rJava.rdb' is corrupt

I have tried setting JAVA_HOME to the jre directory by doing all of these:

Sys.setenv(JAVA_HOME='C:\\Program Files\\Java')
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_121')
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_121\\bin')
Sys.setenv(JAVA_HOME='C:\\Program Files\\Java\\jre1.8.0_121\\bin\\server')

However, none of them seem to work. Before this, I was using the 32 bit version of Java and tried setting it to the 32 bit version (Program Files (x86)). The 32 bit version does not work either.

This is what I get when I query the PATH:

> Sys.getenv("PATH")
[1] "C:\\Program Files\\R\\R-3.3.0\\bin\\x64;C:\\ProgramData\\Oracle\\Java\\javapath;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\WIDCOMM\\Bluetooth Software\\;C:\\Program Files\\WIDCOMM\\Bluetooth Software\\syswow64;C:\\Program Files (x86)\\Common Files\\Roxio Shared\\DLLShared\\;C:\\Program Files (x86)\\Common Files\\Roxio Shared\\10.0\\DLLShared\\;C:\\Program Files (x86)\\Skype\\Phone\\;C:\\Program Files (x86)\\Calibre2\\;C:\\Program Files\\Git\\cmd;C:\\Users\\dell_x\\AppData\\Local\\Microsoft\\WindowsApps;"

I have the latest version of Java installed both in 32 and 64 bit. All I want is to be able to use open rJava in R. None of the paths I've mentioned earlier have worked (I still get an error when loading the Java library into R) and I can't find a specific jre folder or file to set the path to.

Ashishkumar Singh
  • 3,580
  • 1
  • 23
  • 41
Alberto C
  • 91
  • 1
  • 1
  • 5
  • "However none of them seem to work" ...work how? After trying to set `JAVA_HOME` via `Sys.setenv`, what's the output of `Sys.getenv("JAVA_HOME")`? –  Feb 10 '17 at 18:03
  • Also, unless you're trying to point rJava at a particular, non-default JRE, you might want to permanently set `JAVA_HOME` in the control panel... –  Feb 10 '17 at 18:04
  • I get the path I just set. However, I still can't load the rJava package into R. I get the same error message. – Alberto C Feb 10 '17 at 18:06
  • ...what error message? –  Feb 10 '17 at 18:07
  • Error in get(Info[i, 1], envir = env) : lazy-load database 'C:/Users/dell_x/Documents/R/win-library/3.3/rJava/R/rJava.rdb' is corrupt – Alberto C Feb 10 '17 at 18:09
  • Possible duplicate of [Unable to load rJava on R](http://stackoverflow.com/questions/27661325/unable-to-load-rjava-on-r) –  Feb 10 '17 at 18:41
  • I guess what I cannot figure out is the path to the jre for this version of java. When I go to the Java folder in my program files I see a folder named "jre1.8.0_121". I've tried setting the path to this folder but it doesn't work. I've also tried setting it to the "bin" folder inside "jre1.8.0_121" and it doesn't work either. And I've also tried to set it to the "server" folder inside the "bin" folder with no luck. I can't find any specific file called jre so I don't know what is the jre path to get it to work... any suggestions? – Alberto C Feb 10 '17 at 23:48
  • Try setting the path BEFORE you start R. – Hong Ooi Feb 11 '17 at 15:11

1 Answers1

2

This is a duplicate of both: Unable to load rJava on R and Problems loading rJava Package on Win7.

I needed to install the Java SE Development Kit for rJava to work (should have read the package's documents) and then set the JAVA_HOME path to the jre folder inside "jdk1.8.0_121". Finally restart RStudio and everything works fine (I can load the rJava package).

Sorry for the duplicate.

Community
  • 1
  • 1
Alberto C
  • 91
  • 1
  • 1
  • 5