Unable to R Extend in NetLogo
I realize this is not a programming question, but I hope that one of the very experienced NetLogo people can see what I am doing wrong, especially since many of you are working in Java and I am not.
I am trying to hook up an R extension, so I can use the R libraries to do some tricky networking stuff. I am using Windows 7. The detailed installation instructions describe three system variables that need to be set. I did this and repeat them from the command line, R_HOME and JRI_HOME connect to what appears to be suitable directories, and my PATH includes the R bin.
Step 4 of the installation instructions opens R terminal from the command line and works fine. Likewise, loading the rJava library from that terminal (i.e. step 6, enter library(rJava)
) returns an appropriate message. Checking for java versions (step 9) returns matching 64-bit answers, exactly the same as in the documentation, except that my vm version is more recent.
Testing it all (step 12) opens NetLogo and I type extensions [r]
, but the checkmark closes it immediately. According to the documentation, this is a bug with R_HOME and PATH, but I can't see it. On the command line, I get an error Cannot find JRI native library! Please make sure that the JRI native library is in a directory listed in java.library.path
followed by many java errors.
Is there an environment variable I forgot to set? Do I really need to add something to the java.library.path even though this is not documented?
UPDATE
On further investigation, there is an extension called rsystemcheck that comes with the r extension. Installing this [note for others who have this problem, just move the folder to the extensions folder], it looks like I have (at least) two versions of Java installed on my computer. This is not surprising, since the Java update process does not really clean up and many programs install additional versions of the runtime.
The Check java tool tells me that I have versions v1.8.0_51 and v1.6.0_45 installed, and if it is 32 bit and the other is 64 bit, the R extension will not work.
The ratting on my filesystem is v1.8.0_51 definitely 32 bit. I also have v1.7.0 64bit installed (new!). I cannot find v1.6.0_45 directly, but I think it is the version found in the jre folder of the NetLogo installation.
Also, trying to install NetLogo without a VM and pointing to my JRE doesn't work because NetLogo requires the JRE to be 32 bits. Also, removing Java and replacing the 32-bit version doesn't work because I am using 64-bit R.
ok, resolved (if somewhat unsatisfactory). I'm leaving this here because I think other people using Windows want R and NetLogo to talk to each other.
The problem is NetLogo requires 32 bit Java. I have no idea how the R extension developers got the screenshots with 64-bit R, but you really need to use 32-bit R.
(1) uninstall 64bit java and instead install 32bit java
(2) add the 32bit R installation
(3) leave the environment variable %R_HOME% as in instructions
(4) add %R_HOME%\bin\i386 to Path
The important bit is step (4), which makes the R extension find the 32-bit installation of R. There are two bin subdirectories in the R installation directory, one for 64-bit (x64) and one for 32-bit (i386). The path should find the 32-bit version.
Step (1) might be optional - I just don't have the understanding of java required to work with 32 and 64 bit Java.