rJava install error "JAVA_HOME cannot be determined from the Registry"

JavaRError HandlingRjava

Java Problem Overview


I am trying to load the rJava using the command:

 library(rJava)

But I get the following error:

 Error : .onLoad failed in loadNamespace() for 'rJava', details:
   call: fun(libname, pkgname)
   error: JAVA_HOME cannot be determined from the Registry
 Error: package or namespace load failed for ‘rJava’

I tried reinstalling both the Java and the R program with the latest versions but still get these errors.. May I know how I can resolve this? Thank you very much!

Java Solutions


Solution 1 - Java

This error is often resolved by installing a Java version (i.e. 64-bit Java or 32-bit Java) that fits to the type of R version that you are using (i.e. 64-bit R or 32-bit R). This problem can easily effect Windows 7 users, since they might have installed a version of Java that is different than the version of R they are using.

http://www.r-statistics.com/2012/08/how-to-load-the-rjava-package-after-the-error-java_home-cannot-be-determined-from-the-registry/

Solution 2 - Java

Install 64 bit Java from https://java.com/en/download/manual.jsp.
Then in windows cmd run
setx PATH "C:\Program Files\Java\jre1.8.0_211\bin\server;%PATH%"
(make sure your path is correct).

Then in RStudio run
Sys.setenv(JAVA_HOME="")

Now, you should be able to run rJava!!

Solution 3 - Java

I got the same error resolved by installing same version of R and Java i.e. 64 bits and manually updating the path i.e. ,

Sys.setenv(JAVA_HOME='C:/Program Files/Java/jre1.8.0_121') # for 64-bit version

Solution 4 - Java

R for Windows installer installs by default both 32-bit and 64-bit files. Reinstalling R and unticking 32-bit part solved the problem for me.

Solution 5 - Java

As mentioned in the r-statistics link cited above, you have to manually download the 64-bit version of Java. If not, then the 32-bit version will be installed.

So, if you have a 64-bit operating system, then ensure that both R and Java are using the 64-bit installs. Otherwise, this problem will persist.

Solution 6 - Java

Under Windows 10, first check your (running) R-Version:

R.version

If you see something like x86_64, a 64-bit version of Java is needed.

Simply downloading and installing the matching Java version (https://java.com/en/download/manual.jsp) solved the problem for me. No reinstall of R needed (as suggested by other users here). There also was no need to set the path explicitly.

Solution 7 - Java

This has been killing me and I have tried multiple methods above, it doesn't work. After, I mix all solution to try and below process works for me.

  1. Install Java for 64 bit
  2. Run below code in windows command
    setx PATH "C:\Program Files\Java\jre1.8.0_171\bin\server;%PATH%"
    (please change the address acorrding to your dvm.dll real address)
  3. Run below in R studio Sys.setenv(JAVA_HOME="")
    Then I finally can run
    library(rJava)
    library(xlsx)

Solution 8 - Java

I faced the same issue and was feeling very down as I couldnt get my analysis done. This worked for me :

  1. check your operating system. 64 bit or 32 bit. https://helpx.adobe.com/x-productkb/global/determine-whether-computer-running-32.html

  2. uninstall previous versions of Java.

  3. delete rJAVA library from Doc>R>win-library. If you have more than 1 versions of R, make sure you delete rJAVA package from all of them.

  4. install Java based on system requirement (64 bit or 32 bit).

  5. and finally restart R before and after installing rJava package.

Solution 9 - Java

If R is 64-bit version make sure to install Java 64-bit version!

If R is x86-bit version make sure to install Java x86-bit version!

Solution 10 - Java

You can add INSTALL_opts=c("--no-multiarch") to your install_github() call: devtools::install_github("mne-tools/mne-r", INSTALL_opts=c("--no-multiarch"))

For more info: https://github.com/mne-tools/mne-r/issues/5#issuecomment-489588267

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEricView Question on Stackoverflow
Solution 1 - JavaRaja AnbazhaganView Answer on Stackoverflow
Solution 2 - JavaBalasaheb SonawaneView Answer on Stackoverflow
Solution 3 - JavaAnksGView Answer on Stackoverflow
Solution 4 - JavaTomaszGuzialekView Answer on Stackoverflow
Solution 5 - JavaShawn CefaluView Answer on Stackoverflow
Solution 6 - JavaPeterView Answer on Stackoverflow
Solution 7 - JavaXiao QianYuView Answer on Stackoverflow
Solution 8 - JavaVelaView Answer on Stackoverflow
Solution 9 - JavaMina SalehView Answer on Stackoverflow
Solution 10 - JavaupuilView Answer on Stackoverflow