Problems loading a package in R due to rJava

When I type require(xlsx) to load the xlsx package into R, the following messages are displayed:

 > require(xlsx) Loading required package: xlsx Loading required package: xlsxjars Loading required package: rJava Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: JAVA_HOME cannot be determined from the Registry Failed with error: 'package 'rJava' could not be loaded' 

I also tried downloading the rJava package manually, but received this error message:

 require(rJava) Loading required package: rJava Error : .onLoad failed in loadNamespace() for 'rJava', details: call: fun(libname, pkgname) error: No CurrentVersion entry in Software/JavaSoft registry! Try re-installing Java and make sure R and Java have matching architectures. 

Do you have any suggestion on how to solve the problem?

+56
r rjava
Jun 29 '13 at 5:15
source share
8 answers

The reason is probably due to the fact that you are using a 64-bit OS and R, but you do not have Java installed with the same architecture. What you need to do is download Java-64-bit from this page: https://www.java.com/en/download/manual.jsp

After that, just try reloading the xlsx package. You do not need to restart R.

+72
May 19 '14 at 16:13
source share

Because either one of the versions of Java (32 bit / 64 bit) is missing on your computer. Try installing both Jdks and running the code.
After installing Jdks, open R and enter the code

 system("java -version") 

This will give you the Jdk version. Then try downloading the rJava package. It worked for me.

+6
Mar 04 '15 at 7:19
source share

I had a similar problem that I had to set JAVA_HOME with. I am tired first in R:

 Sys.setenv(JAVA_HOME = "C:/Program Files/Java/jdk1.8.0_101/") 

And when it really worked, I set it to System Properties → Advanced → Environment Variables, adding a new system variable. Then I restarted R / RStudio and it worked.

+4
Oct 11 '16 at 20:00
source share

I had a similar problem. This is caused by the dependent package "rJava". This problem can be solved by redirecting R to use another JAVA_HOME .

 if(Sys.getenv("JAVA_HOME")!=""){ Sys.setenv(JAVA_HOME="") } library(rJava) 

It worked for me.

+2
Jun 26. '14 at 21:35
source share

If you have this error in RStudio, use the Lauren environmental code above and change the version of R to a 32-bit version in Tools, Global Options. There should be both 32-bit and 64-bit R-options if you have a newer version. This will require a restart of R and limit the memory settings. However, installing the 64-bit version of jre is not required.

+1
Mar 15 '17 at 17:31
source share

The answer in the link solved my problem.

Prior to resolving, I tried to add JAVA_HOME to the Windows environment. He resolved this error, but created another problem. The solution in this link solves this problem without creating additional problems.

0
Mar 07 '16 at 12:19
source share

An alternative package you can use is readxl . This package does not require external dependencies.

0
Oct 12 '16 at 2:46
source share

If you have this problem with macOS, there is no easy way here :( Especially if you want to use R3.4. I was already there;)

R 3.4, rJava, macOS and even more mess;)

For R3.3, a little easier (R3.3 was compiled using another compiler).

Adventures of R, Java, rJava and macOS

0
Aug 14 '17 at 16:25
source share



All Articles