D. Woods
D. Woods

Reputation: 3073

RNetLogo Class Error

I've got one week old clean install of OS X (10.12.6) with new installs of R (3.4.1), rJava (0.9-8), and Oracle Java 8 (1.8.0_144-b01). I'm having trouble getting RNetLogo (1.0-4) to start (using NLStart()). Also, my version of Netlogo is 6.0.1.

The code I'm running is:

library(RNetLogo)

NLStart("/Applications/NetLogo 6.0.1/Java", 
  gui = FALSE, nl.jarname = "netlogo-6.0.1.jar")

The error I'm experiencing is similar to what many others have experienced with this and previous versions of NetLogo and RNetLogo (examples: 1, 2, & 3). I have tried all of the fixes recommended on each of the links (above) but haven't found one that gets me past this error.

Here are the error messages:

java.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable  
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:348)  
Caused by: java.lang.ClassNotFoundException 
    at RJavaClassLoader.findClass(RJavaClassLoader.java:383)  
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)  
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)  
    ... 2 more

One in one of the message threads above, they suggest that it is a bug in RNetLogo. This may be true, but I can't find an active message board or bug/issue list associated with this package (it is being regularly maintained).

Upvotes: 2

Views: 440

Answers (1)

D. Woods
D. Woods

Reputation: 3073

I reached out to the RNetLogo package maintainer (Jan Thiele) who provided me with an alternate R-based startup procedure for using the NetLogo GUI (credit goes to Robert Schlicht from University of Dresden).

Below is a simplified version of the startup procedure that they provided. To make it work, you may need to install (or reinstall) up-to-date versions of the packages: rJava, JGR, and RNetLogo.

Essentially, the procedure uses base R or RStudio to kick off a different R environment (Java GUI for R -- JGR) that is working with NetLogo on the Mac.

Here's how I start JGR (you may need to adjust the JDK version number):

#Load Java
 dyn.load("/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre/lib/server/libjvm.dylib")
JGR::JGR() #Start JGR

Then in the Java GUI for R (JGR) start NetLogo:

library(RNetLogo)
NLStart("/Applications/NetLogo 6.0.1/Java", nl.jarname = "netlogo-6.0.1.jar")

Notes:

  • The "full" path is required for NLStart's nl.path argument.
  • NetLogo 6.0.2 was recently released and this procedure appears to work fine with that version too.

Upvotes: 2

Related Questions