title: How to set JAVA_HOME and PATH in Windows 10 when loading rJava into R
body: <p>When loading rJava I get the following error message:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I have tried setting JAVA_HOME to the jre directory by doing all of these:</p>
  
  <pre><code>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')
  </code></pre>
  
  <p>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. </p>
  
  <p>This is what I get when I query the PATH:</p>
  
  <pre><code>&gt; 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;"
  </code></pre>
  
  <p>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. </p>