Reputation: 17678
I realise this is not really a programming question, but I am hoping that one of the very experienced NetLogo people here can see what I am doing wrong, especially as many of you work in Java and I don't.
I am trying to connect up the R-extension so I can use R libraries to do some tricky network stuff. I am using Windows 7. The detailed installation instructions describe three system variables that must be set. I have done so and echoing them from the command prompt, R_HOME and JRI_HOME connect to what appear to be the appropriate directories and my PATH includes the R bin.
Step 4 of the installation instructions opens an R terminal from command line and that works fine. Similarly, loading the rJava library from within that terminal (that is step 6, entering library(rJava)
) returns the appropriate message. The check on java versions (step 9) returns the appropriate 64 bit responses, exactly the same as in the documentation except that my vm version is more recent.
Testing it all together (step 12) opens NetLogo and I type extensions [r]
but the check tick closes it immediately. According to the documentation, this is an error with R_HOME and PATH, but I can't see it. In 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 need to actually add something to the java.library.path even though that's not described in the documentation?
UPDATE
On further investigation, there is an extension called rsystemcheck that is shipped with the r extension. Installing that [note for others who have this problem, simply move the folder into the extensions folder], it appears that my computer has (at least) two versions of Java installed. This is not terribly surprising as the Java update process doesn't really clean up and lots of programs install additional versions of the runtime.
The 'Check java' tool reports that I have v1.8.0_51 and v1.6.0_45 installed and that if one is 32bit and the other is 64bit then the R extension won't work.
Ratting around in my file system - v1.8.0_51 is definitely 32bit. I also have v1.7.0 64bit (a new one!) installed. I can't find v1.6.0_45 directly, but I think this is the version that is in the jre folder of the NetLogo installation.
Furthermore, trying to install NetLogo without the VM and pointing to my JRE does not work because NetLogo requires the JRE to be 32bit. Further, uninstalling java and replacing with the 32bit version does not work because I use 64bit R.
Upvotes: 3
Views: 1318
Reputation: 31
I think the key is to make sure all your software is either 64 bit or 32 bit. I can open R from NetLogo successfully by using all 64 bit R, Java and NetLogo. My working code can be found here. https://raw.githubusercontent.com/tonysdatamodels/netlogo.in.r/main/open%20netlogo%20in%20r. I also have a short video on youtube video explaining how to successfully open NetLogo from R https://www.youtube.com/watch?v=zWMdaTEPTOc .
Upvotes: 0
Reputation: 17678
okay, solved (if somewhat unsatisfactorily). I am leaving this here because I imagine other people using Windows want R and NetLogo to talk to each other.
The problem is that NetLogo requires 32 bit Java. I have no idea how the developers of the R extension(s) got screenshots with 64bit R, but what you really need to do is 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. The R installation directory has two bin subdirectories, one for 64bit (x64) and one for 32bit (i386). The Path needs to find the 32 bit version.
Step (1) may be optional - I simply don't have the java understanding necessary to work out how to deal with 32 and 64 bit versions of java.
Upvotes: 1