Post

4 followers Follow
1
Avatar

Package ‘rJava’ could not be loaded

Hi,
I have read previous problems about "rjava", but I still can not solve my problem from previous solutions.
I use the "xlsx" package to read .xlsx file in R. it require 2 packages : "rJava" and "xlsxjars". On Rstudio, I have install "xlsxjars", "rjava" and "xlsx" packages, however every time I library "xlsx", It always slows :

library(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
錯誤: package ‘rJava’ could not be loaded

My condition :
R : 2.15.2
OS : win 7

Thank you very much!

Ian Pylvainen

7 comments

0
Avatar

Emily,

This is actually a question about R (rather than about RStudio) and you might be able to find an answer by using the additional resources in this Knowledge Base Article:

http://support.rstudio.org/help/kb/troubleshooting/getting-help-with-r

That siad, based on your error, you probably need to install Java. See the following blog post on this error:

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

Best of luck,

Josh

Ian Pylvainen 0 votes
0
Avatar

It's very helpful. Following your suggestion, I solved the problem.

The most important part is:

Sys.setenv(JAVA_HOME='C:\Program Files\Java\jre7') # for 64-bit version
Sys.setenv(JAVA_HOME='C:\Program Files (x86)\Java\jre7') # for 32-bit version
library(rJava)

Jeremy Chu 0 votes
0
Avatar

sorry but even after installing the correct version of Java the problem continues

I am getting an error:

Error: could not find function "readWorksheetFromFile"

AbdulRashid Sipoy 0 votes
0
Avatar

I got it resolved..... actually by removing the 32 bit version... I had both the versions installed.... now there is no error... thanks for the solution....

AbdulRashid Sipoy 0 votes