jonny jonny - 3 months ago 37
R Question

Error caused by rJava when loading ReporteRs package

I have problems loading

ReporteRs
in R. I get the following message:

Loading required package: ReporteRsjars
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.
Error: package ‘ReporteRsjars’ could not be loaded


I have Java version "1.8.0_25",
rJava
,
ggplot2
and
ReporteRsjars
installed.

Answer

Here is a range of possible solutions for you to explore:

Install the latest rJava version. Earlier versions may not work! Mirrors are not up-to-date, so go to the source at www.rforge.net: http://www.rforge.net/rJava/files/. Note the advice there “Please use install.packages('rJava',,'http://www.rforge.net/') to install.”

That is almost correct. This actually works: install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/') Watch the punctuation! The mysterious “.libPaths()[1],” just tells R to install the package in the primary library directory. For some reason, leaving the value blank doesn’t work, even though it should default.

Tell R about the updated java version If you just changed your java version, make R aware of this by running R CMD javareconf from terminal.

Add jvm.dll to your PATH and have it in the proper directory rJava, the R<->Java bridge, needs jvm.dll, but R will have trouble finding it. It resides in a folder like C:\Program Files\Java\jdk1.6.0_25\jre\bin\server or C:\Program Files\Java\jre6\jre\bin\client Wherever yours is, add that directory to your windows PATH variable. (Windows -> "Path" -> "Edit environment variables to for your account" -> PATH -> edit the value.)

You may already have Java on your PATH. If so you should find the client/server directory in the same Java "home" dir as the one already on your PATH.

It seems that rJava searches for jvm.dll in ~\Java\jre6\bin\client. However this folder didn´t exist on my system (jvm.dll was in ~\bin\server). So one workaround is to make a copy of jvm.dll in a folder ~\bin\client\ and added this to the path.

Define the path for R to find java options(java.home="C:/Program Files/Java/jre7/") Change it appropriately

Make sure your architectures match. If you have Java in Program Files, it is 64-bit, so you ought to run R64. If you have Java in Program Files (x86), that's 32-bit, so you use plain 32-bit R.

Re-launch R from the Windows Menu If R is running, quit. From the Start Menu , Start R / RGUI, RStudio. This is very important, to make R pick up your PATH changes.