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

Dieter Menne dieter.menne at menne-biomed.de
Mon Jan 26 09:36:58 CET 2009


Duncan Murdoch <murdoch <at> stats.uwo.ca> writes:

> 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 "/".

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

> p = Sys.getenv("PATH")
> nchar(p) 
PATH 
1019 
> strsplit(p,";")$PATH[-(1:27)]
[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"
>




More information about the R-help mailing list