9

Yesterday I removed R2.11 from my system (Win7, 64bit), since I´m working on R2.13.

Since then i get an error message:

> require(rJava)
Lade nötiges Paket: rJava
Error : .onLoad in loadNamespace() fehlgechlagen, Details:
  Aufruf: rJava
  Fehler: inDL(x, as.logical(local), as.logical(now), ...)

I tried specifying PATH, since I found on the internet that it might have something to do with jvm.dll:

c:\Rtools\bin;
c:\Rtools\perl\bin;
c:\Rtools\MinGW\bin;
c:\Rtools\MinGW64\bin;
C:\Windows\system32;
%R_HOME%\bin;
C:\Program Files\R\R-2.13.0\bin; 
C:\Program Files\Java\jre6\bin\server

However I could not solve the problem... I also can´t run R from the win command line (just type "R"?)

Any suggestions?

4
  • You can't load R from the command line which means that your paths for R are messed up. You can either reinstall 2.13 or fix paths yourself. You will need this to run R natively. If you run it from an IDE, there are other possibilities. Are you using an IDE? If so, which one? Commented Jun 27, 2011 at 12:00
  • Most time i am using RStudio. But i would prefer to fix the paths... At the moment i´m trying to fix them, but without success, yet....
    – EDi
    Commented Jun 27, 2011 at 12:04
  • The problem with loading R from console is fixed (path: "C:\Program Files\R\R-2.13.0\bin\x64"). But rJava still doesn´t load.
    – EDi
    Commented Jun 27, 2011 at 12:13
  • %R_HOME%\bin is suspicious. Also since 2.12 there are architecture depended subdirectories in bin (bin/x64 and bin/i386). My advice: change C:\Program Files\R\R-2.13.0\bin to C:\Program Files\R\R-2.13.0\bin\x64 and %R_HOME%\bin to %R_HOME%\bin\x64 (and check if %R_HOME% is 2.13).
    – Marek
    Commented Jun 27, 2011 at 13:29

8 Answers 8

22

Here is some quick advice on how to get up and running with R + rJava on Windows 7 64bit. There are several possibilities, but most have fatal flaws. Here is what worked for me:

Add jvm.dll to your PATH

rJava, the R<->Java bridge, will need jvm.dll, but R will have trouble finding that DLL. 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.

To be safe, 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.

Install rJava 0.9.2.

Earlier versions do 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.

1
  • Thanks you for your instructions. its works for me :) +1 Commented May 5, 2017 at 1:50
3

I finally solved the problem:

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 I just made a copy of jvm.dll in a folder ~\bin\client\ and added this to the path.

Now everything works fine!

2
  • 1
    I still get a failure with Java 7. I created a "client" folder (there wasn't one there), copied jvm.dll from "server" and added jre7\bin\client to the path. Still a "%1 is not a valid Win32 application" and a failure to load rJava.dll"
    – bshor
    Commented May 20, 2013 at 23:32
  • do you have JDK installed at all?
    – userJT
    Commented May 2, 2016 at 21:42
3

My problem was solved by

install.packages("SqlRender",INSTALL_opts="--no-multiarch")

It was a package that depends on rJava and all advices were telling me to fix Java installation. But the solution was to use install option that simply forgets about i386 architecture. (also works with drat library and packages not from CRAN)

1

This may be due to a conflict between RStudio and Java versions. If you have installed 64 bit java and RStudio is running in 32 bit mode, you may experience problems like this. As a solution, you can change the 32-64 bit selection in the Tools-> Global Options-> General section in RStudio. You can find detailed information here.

0

In my case installing proper version of Java solved my problem. I installed 64x bit java, cause I use 64x bit R version.

0

I solved it by following these steps

  • setting my environment Sys.setenv(JAVA_HOME='C:\\Program Files (x86)\\Java\\jre6')
  • Manually installing rJava package from install package (even this should work: install.packages('rJava', .libPaths()[1], 'http://www.rforge.net/'))
  • library(rJava)
0

I solved this problem as follows. I've been trying for 2 days. Windows 7 users do not write ... \ bin \ x64 in environment variables. Instead, define the path as follows. JAVA_HOME "C: \ Program Files \ Java \ jre1.8.0_251" R_HOME C: \ Program Files \ R \ R-3.5.3

-1
  • In RStudio type .LibPaths()
  • This will give you an path in you windows system where your library’s are located
  • Go there and delete rJava. If it is being used by applications of Java, kill all Java programs in the Task Manager.

  • Go to computer and properties, click on change environment variables

  • Edit JAVA_HOME and all Java related paths to the path where your newest installation of Java is located and save.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.