Reputation: 2081
I am using macOS Sierra and R version 3.4.1 and java version "1.8.0_144". I am trying a simple example adapted from the RNetLogo manual:
require(RNetLogo)
require(tidyverse)
require(extrafont)
loadfonts()
nl.path <- "/Applications/NetLogo 6.0.1"
NLStart(nl.path)
model.path <- "/models/Sample Models/Earth Science/Fire.nlogo"
absolute.model.path <- paste(nl.path,model.path,sep="")
NLLoadModel(absolute.model.path)
But the command NLLoadModel gives the following error:
Error in .jcall(nl.obj, "V", "loadModel", .jnew("java/lang/String", model.path)) :
RcallMethod: invalid object parameter
This also happens in Windows also with Java version 1.8.
Upvotes: 3
Views: 437
Reputation: 2081
Using the Fire.nlogo model in macOS Sierra, I found two solutions (see the manual of RNetLogo): First, with gui=FALSE
Sys.setenv(NOAWT=1)
require(RNetLogo)
nl.path <- "/Applications/NetLogo 6.0.1/Java"
nl.path2 <- "/Applications/NetLogo 6.0.1"
NLStart(nl.path, gui=FALSE, nl.jarname='netlogo-6.0.1.jar')
model.path <- "/models/Sample Models/Earth Science/Fire.nlogo"
absolute.model.path <- paste(nl.path2,model.path,sep="")
NLLoadModel(absolute.model.path)
# Fire from manual
NLCommand("setup")
NLDoCommand(10, "go")
burned <- NLReport("burned-trees")
print(burned)
NLQuit()
Then with gui=TRUE:
Sys.setenv(NOAWT=1)
require(JGR)
Sys.unsetenv("NOAWT")
JGR()
# Now using JGR
require(RNetLogo)
nl.path <- "/Applications/NetLogo 6.0.1/Java"
nl.path2 <- "/Applications/NetLogo 6.0.1"
NLStart(nl.path, gui=TRUE, nl.jarname='netlogo-6.0.1.jar')
model.path <- "/models/Sample Models/Earth Science/Fire.nlogo"
absolute.model.path <- paste(nl.path2,model.path,sep="")
NLLoadModel(absolute.model.path)
# Fire from manual
NLCommand("setup")
NLDoCommand(10, "go")
burned <- NLReport("burned-trees")
print(burned)
NLQuit()
Upvotes: 1