Skip to content

can't load rJava in R 2.8.1 on Windows XP

12 messages · Brian Ripley, drflxms, Dieter Menne +1 more

#
Dear community,

unfortunately I did not manage load the rJava package receiving the following
error-message:
Error in inDL(x, as.logical(local), as.logical(now), ...) : 
kann shared library 'C:/Programme/R/2.8.1/library/rJava/libs/rJava.dll' nicht
laden:
LoadLibrary failure:  Das angegebene Modul wurde nicht gefunden.

Error : .onLoad in 'loadNamespace' f?r 'rJava' fehlgeschlagen
Fehler: Laden von Paket/Namensraum f?r 'rJava' fehlgeschlagen


Translation: 
can't load library ... rJava.dll
LoadLibrary failure: the module was not found

Reinstalling the package did not help, installing the latest developement
version didn't help as well.

The shared library rJava.dll is in place (exactly where R is looking for it)!

Are there any ideas, what's wrong.
I'd appreciate any kind of help very much, as I need rJava urgently to use RWeka and iPlots.

Best regards,
Felix
#
Most likely Java is not in place, including in the DLL search path.
On Fri, 23 Jan 2009, drflxms wrote:

            
You should get a popup here with more information (from Windows).  The 
problem is not rJava.dll, but one of its dependencies.

  
    
#
On 1/23/2009 7:38 AM, drflxms wrote:
That message comes from Windows, not R, and it's misleading.  It does 
not say that rJava.dll was not found, it says that a DLL needed by it is 
not found.  It would be helpful if it told you which one.  You should 
complain to Microsoft about it.  If rJava.dll had been missing, the 
English message would have been

   shared library 'rJava' not found

The pedump utility (in the Rtools set, see 
www.murdoch-sutherland.com/Rtools) can tell you what the dependencies are:

pedump -i rJava.dll

shows that it imports things from these dlls:

  R.dll
  KERNEL32.dll
  msvcrt.dll
  jvm.dll

The first 3 are routine; without those R wouldn't work. (Without 
KERNEL32.dll, nothing in Windows would work.)  So as Brian said, it's 
likely jvm.dll that it can't find, or possibly a DLL that it depends on.
Did you install Java first, as rJava requires?

Duncan Murdoch
#
Dear Mr. Murdoch, Dear Mr. Ripley, Dear Mr. Wang,

thank you very much for your quick and efficient help! It is exactly as
Duncan explained it: Including jvm.dll in PATH solved the problem
immediately. Everything works fine now.

The only thing is, that I do not understand why I had to do this
manualy, as I installed Java Runtime Environment a long time ago,
updated frequently and never encountered any difficulties in using Java
software.

Anyway, I am happy now :-)
Thanx again for your great support!
Greetings from Munich, Germany,

Felix

Duncan Murdoch schrieb:
#
On 1/23/2009 9:44 AM, drflxms wrote:
If you look at rJava:::.onLoad now that you can load the package, you'll 
see that it goes through a number of tests to try to find the right 
path.  Those work on my system (and presumably on Simon Urbanek's, the 
rJava maintainer), but not on yours.  It might be helpful to him if you 
could find some small change to his search that would work on systems 
like yours, even without adding the jvm.dll path to the general PATH. 
(I don't have it in mine.)

Duncan Murdoch
#
Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
Slightly different for me, but failure: 

jvm.dll is on path (checked successfully with "where jvm.dll")

Rgui: Dialog Box (Translated from German)

R Console: RGui.exe Component not found

The application could not be started because jvm.dll could not be found.

rJava package as of today

R version 2.8.1 (2008-12-22) 
i386-pc-mingw32 

locale:
LC_COLLATE=German_Germany.1252;LC_CTYPE=German_Germany.1252;
LC_MONETARY=German_Germany.1252;LC_NUMERIC=C;LC_TIME=German_Germany.1252

attached base packages:
[1] stats     graphics  grDevices datasets  utils     methods   base
#
On 1/23/2009 12:06 PM, Dieter Menne wrote:
From within R?  Remember that the PATH is process-specific.  Maybe your 
shell added something that put jvm.dll on its path, but you didn't start 
Rgui from there.

In any case, looking at the .onLoad, it appears the easiest thing to do 
is to define the environment variable JAVA_HOME.  The startup code puts 
$JAVA_HOME/bin, $JAVA_HOME/bin/client, and $JAVA_HOME/jre/bin/client 
onto the end of the path, so things should work if at least one of those 
has your jvm.dll in it.

Duncan Murdoch
#
Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
JAVA_HOME had been defined (that's how I started, after reading the c code).


In RGui
C:\Program Files\Java\jre6\bin\client\jvm.dll
JAVA_HOME=C:\Program Files\Java\jre6
And yet : the dialog box as mentioned, and, after clicking Ok:

Error in inDL(x, as.logical(local), as.logical(now), ...) : 
  unable to load shared library
'C:/PROGRA~1/R/R-28~1.0/library/rJava/libs/rJava.dll':
  LoadLibrary failure:  Das angegebene Modul wurde nicht gefunden.


Error : .onLoad failed in 'loadNamespace' for 'rJava'
Error: package/namespace load failed for 'rJava'
If it matters: same problem from Rterm. To be sure it is not a security 
problem under Vista, I also run both RGui and Rterm as admin. Same.

Dieter
#
Dieter Menne wrote:
That doesn't last beyond the shell call, as far as I know.  It starts a 
process to run the shell, sets the environment variable in that process, 
then the process dies and the setting dies with it.  If you want a 
permanent setting, you should set it in the Rgui process, via Sys.setenv().

Duncan Murdoch
#
Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
Trying again (after reading your private email): I tried to start 
libary(rJava) after each of the following line, and the result 
was always the same.

Dieter


shell("where jvm.dll")
#C:\Program Files\Java\jre6\bin\client\jvm.dll
Sys.getenv("JAVA_HOME")
#                       JAVA_HOME 
#"C:/Program Files/Java/jre6/bin" 
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jre6")
Sys.setenv(JAVA_HOME="C:/Program Files/Java/jre6/bin")
Sys.setenv(JAVA_HOME="C:\\PROGRA~1\\Java\\jre6")
Sys.unsetenv("JAVA_HOME")
#
On 24/01/2009 3:56 PM, Dieter Menne wrote:
I don't know what's going wrong on your system.  I added a browser() 
call to the .onLoad function in R/windows/FirstLib.R on my system, and I 
see it successfully gets JAVA_HOME from the registry.  It gets a number 
of other files, then adds these paths to my PATH variable.  I've used 
strsplit() to separate them for viewing.

[14] "C:\\Program Files\\Java\\jre1.6.0_07\\bin\\client"
[15] "C:\\Program Files\\Java\\jre1.6.0_07/bin"
[16] "C:\\Program Files\\Java\\jre1.6.0_07/bin/client"
[17] "C:\\Program Files\\Java\\jre1.6.0_07/jre/bin/client"

I believe LoadLibrary needs paths to be specified with backslashes, so 
you might be able to fix things on your system by changing the file.path 
calls in that function to use fsep="\\" instead of the default "/".

Duncan Murdoch
1 day later
#
Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
Thanks for your help. 

I think I tracked it down. It has nothing to do with rJava, but
rather with Sys.getenv(). Looks like this function truncates around 1024
characters, and my path is very long due to Visual Studio + Delphi
+ SQL Server.

See the printout below. Note that the last entry should read \\Delphi,
and that more entries are coming in my system path.
This also explains why only some people have the problem.
No workaround found yet. I keep this message here for other people who 
have the problem, but possibly this is more for R-devel to be continued.

Dieter
PATH 
1019
[1] "C:\\Program Files\\Microsoft SQL
Server\\100\\Tools\\Binn\\VSShell\\Common7\\IDE\\"
[2] "C:\\Program Files\\MiKTeX 2.7\\miktex\\bin"                           
[3] "C:\\Users\\Dieter\\Documents\\Delp"