[R] can't load rJava in R 2.8.1 on Windows XP

Duncan Murdoch murdoch at stats.uwo.ca
Sat Jan 24 22:26:53 CET 2009


On 24/01/2009 3:56 PM, Dieter Menne wrote:
> Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:
> 
>>>> shell("set JAVA_HOME")
>>>>     
>>> JAVA_HOME=C:\Program Files\Java\jre6
>>>   
>> 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().
> 
> 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.

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

> 
> 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")
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list