Reputation: 420
I'm trying to run NetLogo 5.3.1 on R 3.3.1 through rStudio 0.99.903 on my mac 10.10.6. I've also installed Java 1.8.0_77-b03
> system("java -version")
java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)
> .jinit()
> .jcall("java/lang/System", "S", "getProperty", "java.runtime.version")
[1] "1.8.0_77-b03"
>
> Sys.getenv('JAVA_HOME')
[1] ""
> Sys.getenv('LD_LIBRARY_PATH')
[1] ":@JAVA_LD@"
I'm also running RNetLogo_1.0-2 y rJava_0.9-9.
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RNetLogo_1.0-2 igraph_1.0.1 rJava_0.9-9
loaded via a namespace (and not attached):
[1] magrittr_1.5 rsconnect_0.5 tools_3.3.1
The error I get when I trie to lunch netlogo is as follows.
> nl.path <- ("/Applications/NetLogo 5.3.1/Java")
> ### Start NetLogo
> NLStart(nl.path)
java.awt.HeadlessException
at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204)
at java.awt.Window.<init>(Window.java:536)
at java.awt.Frame.<init>(Frame.java:420)
at java.awt.Frame.<init>(Frame.java:385)
at javax.swing.SwingUtilities$SharedOwnerFrame.<init>(SwingUtilities.java:1758)
at javax.swing.SwingUtilities.getSharedOwnerFrame(SwingUtilities.java:1833)
at javax.swing.JOptionPane.getRootFrame(JOptionPane.java:1696)
at javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:863)
at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:666)
at javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:637)
at nlcon.NLink.<init>(NLink.java:109)
I've tried several solutions that I've found here at StackExchange or here and there.
http://conjugateprior.org/2014/12/r-java8-osx/
http://charlotte-ngs.github.io/2016/01/MacOsXrJavaProblem.html
https://github.com/snowflakedb/dplyr-snowflakedb/wiki/Configuring-R-rJava-RJDBC-on-Mac-OS-X
http://stackoverflow.com/questions/35179151/cannot-load-r-xlsx-package-on-mac-os-10-11
http://stackoverflow.com/questions/14915898/rnetlogo-function-nlstart-fails-to-launch-gui
None of them have worked on my computer ...
does anyone have any idea what should I have to do to make this work?
Thanks!
PS1/ I have the same exact results running R from the mac shell.
PS2/ I've installed java 1.6 and after test the issue and see that doesn't make any change I deleted it.
Upvotes: 1
Views: 398
Reputation: 420
As someone commented (I really don't know why they didn't post the answer) the key to the problem was I was using the wrong package to start NetLogo.
First of all one have to be sure that R has the correct Java Home set. So run this on mac shell.
R CMD javareconf
Then, on R shell / console we have to install the rJava in source way to compile with our Java location and version.
install.packages("rJava", type="source", repos="http://cran.us.r-project.org”)
Then we have to install JGR
install.packages("JGR")
and run and open the JGR console.
require(JGR)
### Start JGR
JGR()
Form there on... we run the rest of the script / commands on the JGR console.
### call netlogo. Set the path where NetLogo is installed
nl.path <- ("/Applications/NetLogo 5.3.1/") # Mac path
### Start NetLogo
# The /Java directory is where the NetLogo java app lives. Don't set
# completely before to make the models path work
NLStart(file.path(nl.path, "Java"))
It should work.
PS/ As you can read here, this functions isn't supported on NetLogo for mac and linux
Upvotes: 2