RNetlogo and NetLogo 5.3 error

2019-02-15 18:47发布

问题:

I have been using RNetLogo with NetLogo 5.2.1 without troubles. Now I am using NetLogo 5.3 and I get this error:

> library(RNetLogo)
> nl.path <- "/Applications/NetLogo 5.3/"
> NLStart(nl.path, gui = FALSE)
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

> sessionInfo()
R version 3.2.2 (2015-08-14)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.2 (El Capitan)

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RNetLogo_1.0-1 igraph_1.0.1   rJava_0.9-8   

loaded via a namespace (and not attached):
[1] magrittr_1.5

Any ideas about what the problem could be?

回答1:

Change your line nl.path <- "/Applications/NetLogo 5.3/" to nl.path <- "/Applications/NetLogo 5.3/app" NetLogo has changed its directory structure; the netlogo jar file is now in an 'app' subdirectory.

You may also need to check the environment variables that you set up as part of the RNetLogo installation.



回答2:

For NetLogo version 5.3.1 the following works if you want to start NetLogo up in headless mode from R on a Mac:

First, before loading the RNetLogo library, execute

Sys.setenv(NOAWT=1)

Then, execute the following:

library(RNetLogo)
setwd("/Applications/NetLogo 5.3.1/Java")
nl.path <- getwd()
NLStart(nl.path, gui = FALSE)


标签: r netlogo rjava