Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problems when trying to load a package in R due to rJava

Tags:

r

rjava

r-xlsx

When I type require(xlsx) in order to load the package xlsx in R, the following messages is shown:

> 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've also tried to load the rJava package manually but got 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?

like image 894
Pritam Kar Avatar asked Jun 29 '13 05:06

Pritam Kar


People also ask

What is rJava package in R?

rJava provides a low-level bridge between R and Java (via JNI). It allows to create objects, call methods and access fields of Java objects from R. rJava release versions can be obtained from CRAN - usually install. packages("rJava") in R will do the trick.

What is rJava?

rJava is a JNI (Java Native Interface)-based, R-to-Java interface with which Java objects may be created and Java methods called and Java fields accessed from R. In this tutorial, we shall get started with using the rJava R package to use Java from R. This tutorial has the following sections: Setting the Environment.


1 Answers

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

After that just try to reload the xlsx package. You shouldn't need to re-start R.

like image 186
Gianluca Avatar answered Oct 08 '22 13:10

Gianluca