Error in NLStart while running RNetLogo package

54 views
Skip to first unread message

Yuyang Zhang

unread,
Apr 1, 2024, 12:57:23 PMApr 1
to netlogo-users
Hello everyone!
I am encountering an error while trying to run the RNetLogo package in R. 
The code is:
nl.path <- "C:/Program Files/NetLogo 6.0.3/app"
nl.jarname <- "netlogo-6.0.3.jar"
NLStart(nl.path,gui=TRUE,nl.jarname)

 When attempting to load NetLogo, I receive the following error message from Java:

"Error in setting cp. Class path is E:/work app/R language/R-4.2.3/library/rJava/java/boot;
E:\work app\R language\R-4.2.3\library\RNetLogo\java;
E:\work app\R language\R-4.2.3\library\RNetLogo\java\RNetLogo.jar"
Snipaste_2024-04-01_15-29-44.png
Details:

I have verified that the class path is correctly set in R using the .jclassPath() function, which returns the following paths:

"E:/work app/R language/R-4.2.3/library/rJava/java"
"E:/work app/R language/R-4.2.3/library/RNetLogo/java"
"E:/work app/R language/R-4.2.3/library/RNetLogo/java/RNetLogo.jar"
Snipaste_2024-04-01_15-59-26.png


Click the OK button in java, the error message I receive in R is:

java.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
Caused by: java.lang.ClassNotFoundException
at RJavaClassLoader.findClass(RJavaClassLoader.java:396)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 2 more

I suspect that the issue may be related to the use of different path separators ("/" and "") in Java compared to R. Although the class paths appear to be correct in R, it seems that Java is not recognizing them properly.

I would greatly appreciate any assistance in resolving this class path issue with the RNetLogo package. If anyone has encountered a similar problem or has any suggestions or insights, please let me know. Specifically, I would like to understand how to resolve the discrepancy between R and Java regarding the path separators.

Thank you in advance for your help.


Aaron Andre Brandes

unread,
Apr 2, 2024, 4:18:37 PMApr 2
to Yuyang Zhang, netlogo-users

Hi,

The first thing for you to know is that RNetLogo is a project that makes use of NetLogo, but is developed independently of us.

Its creator Volker Grimm posted earlier to this group that RNetLogo is not currently being maintained, so it might not be the right choice for your project.

You may find it useful to check previous questions about RNetLogo in this group.

In case it might be relevant I want to note that in NetLogo 6.4.0 BehaviorSpace has a new syntax that allows users to specify a multiple sets of parameters for https://ccl.northwestern.edu/netlogo/docs/behaviorspace.html#subexperiment-syntax. Previously users had to specify a combinatoric space of parameters. This is a feature that was requested by some previous users of RNetLogo.

 

I have included some directions on using the R Extension after the next section, however My first advice would be to switch to the Simple R Extension if possible.

The Simple R Extension

 

 

This extension is available for download and install in the Extensions Manager inside the NetLogo app.

The Simple R Extension is much simpler to setup, you merely need to choose your RScript binary location (or have it on the PATH) and the rest should just work.

You can learn how to use it here https://github.com/NetLogo/SimpleR-Extension/blob/main/README.md#using.

The documentation has a section on migrating from the R Extension and most prims map directly over.

 

 

The R extension

Detailed instructions for configuring the R extension on Windows 10 follow.

Note: I last did the installation in 2021, so at the very least you should substitute R 4.2.3 for R 4.0.4

 

To make the process easier for us to help you debug, we recommend downloading and installing NetLogo 6.4.0http://ccl.northwestern.edu/netlogo/download.shtml

 

You may have completed many of these steps already.

 

The key steps once everything is downloaded and updated are:

 

  *   Edit the user.properties file

  *   Edit the System Environment Variable “Path”

These steps have bold headers below

 

Here are the full  instructions<ccl.northwestern.edu/netlogo/docs/r.html#installing> for installing R and configuring it with the extension.

Pay particular attention to the Windows-specific installation steps<ccl.northwestern.edu/netlogo/docs/r.html#windows-specific-installation-steps>

 

Here are the specific steps I took previously to get the R extension running on Windows 10.

 

 

Install R and R packages

I downloaded R 4.0.4 for Windows<cran.r-project.org/bin/windows/base>  and ran the installer with default options plus installing a desktop icon.

I opened R by double clicking the desktop icon.

I typed

install.packages("rJava")

For installation of the packages I accepted the default local location, and chose a mirror site for downloading

Next

install.packages("JavaGD") # Optional

install.packages("CommonJavaJars") # Optional

 

Collect system information

I collected the necessary system information

R.home(component = "home")

[1] "C:/PROGRA~1/R/R-40~1.4"

 

system.file("jri", package = "rJava")

[1] "C:/Users/MyName/Documents/R/win-library/4.0/rJava/jri"

 

Install the Microsoft Visual C++ 2013 if you don’t have it

I tried the Microsoft Visual C++ 2013 redistributable download<microsoft.com/en-us/download/details.aspx?id=40784>

 

And chose the installer vcredist_x64.exe

I double clicked on the installer. Because Microsoft Visual C++ 2013 had been previously installed, the Installer options were “modify setup” and “repair.”

I therefore quit the installer, but you should proceed if it offers to install the software.

 

Edit the user.properties file

Note: I have substituted “MyName” for my actual username throughout this email, and you should substitute in your username when making the changes.

The one discrepancy I ran into is that there was no file C:\Users\MyName\AppData\Roaming\NetLogo\6.2\r\user.properties

The directory existed but was empty.

 

You can download the user.properties file I have attached to the folder  C:\Users\MyName\AppData\Roaming\NetLogo\6.2\r

 

You should then edit the following lines to reflect your name and R installation. (You might be able to edit directly in NotePad because I already did the step of opening and saving with WordPad. Make sure that the resulting filename does not have the suffix .txt)

 

r.home=C:/PROGRA~1/R/R-40~1.4

jri.home.paths=C:/Users/MyName/Documents/R/win-library/4.0/rJava/jri

r.lib.paths=C:/Users/MyName/Documents/R/win-library/4.0

 

Edit the System Environment Variable “Path”

After that you need to edit your system environment variable Path

Use the New button to add the line (adapted if necessary)

C:\Program Files\R\R-4.0.4\bin\x64\

 

You will need to log in and out of Windows, or do a restart for the environment variable change to take effect.

 

Please note that most NetLogo extensions are usable “out of the box.” The R extension requires an atypical amount of configuration steps.

 

Please let us know if this leads to success, or if you need more help write us and include details of steps that have not worked, and error messages you have seen.

Thanks,

Aaron

 

-- 

Aaron Brandes, Software Developer

Center for Connected Learning and Computer-Based Modeling

 

 

From: netlog...@googlegroups.com <netlog...@googlegroups.com> on behalf of Yuyang Zhang <lujia...@gmail.com>
Date: Monday, April 1, 2024 at 12:57
PM
To: netlogo-users <netlog...@googlegroups.com>
Subject: [netlogo-users] Error in NLStart while running RNetLogo package

Hello everyone!

I am encountering an error while trying to run the RNetLogo package in R. 

The code is:

nl.path <- "C:/Program Files/NetLogo 6.0.3/app"
nl.jarname <- "netlogo-6.0.3.jar"
NLStart(nl.path,gui=TRUE,nl.jarname)

 

 When attempting to load NetLogo, I receive the following error message from Java:

"Error in setting cp. Class path is E:/work app/R language/R-4.2.3/library/rJava/java/boot;
E:\work app\R language\R-4.2.3\library\RNetLogo\java;
E:\work app\R language\R-4.2.3\library\RNetLogo\java\RNetLogo.jar"


Details:

I have verified that the class path is correctly set in R using the .jclassPath() function, which returns the following paths:

"E:/work app/R language/R-4.2.3/library/rJava/java"
"E:/work app/R language/R-4.2.3/library/RNetLogo/java"
"E:/work app/R language/R-4.2.3/library/RNetLogo/java/RNetLogo.jar"

 

 

Click the OK button in java, the error message I receive in R is:


java.lang.NoClassDefFoundError: org/nlogo/workspace/Controllable
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
Caused by: java.lang.ClassNotFoundException
at RJavaClassLoader.findClass(RJavaClassLoader.java:396)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 2 more

 

I suspect that the issue may be related to the use of different path separators ("/" and "") in Java compared to R. Although the class paths appear to be correct in R, it seems that Java is not recognizing them properly.

I would greatly appreciate any assistance in resolving this class path issue with the RNetLogo package. If anyone has encountered a similar problem or has any suggestions or insights, please let me know. Specifically, I would like to understand how to resolve the discrepancy between R and Java regarding the path separators.

Thank you in advance for your help.

 

 

--
You received this message because you are subscribed to the Google Groups "netlogo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netlogo-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netlogo-users/008bf495-fb3d-4d79-a4c1-b54eac8d7b3cn%40googlegroups.com.

Volker Grimm

unread,
Apr 3, 2024, 11:11:28 AMApr 3
to Yuyang Zhang, netlogo-users

Hi Yuyang,

 

I am sorry, but the RNetLogo package has not been maintained any more for many years, I am not sure it can be made running still with some tricks. I recommend you use the nlrx package instead, by Salecker et al.: Salecker, J., Sciaini, M., Meyer, K. M., & Wiegand, K. (2019). The nlrx r package: A next‐generation framework for reproducible NetLogo model analyses. Methods in Ecology and Evolution, 10(11), 1854-1863.

 

Cheers,

Volker

--

image001.png
image002.png

diego diaz

unread,
Apr 3, 2024, 11:11:40 AMApr 3
to Yuyang Zhang, netlogo-users
Hi i was struggling with those paths too, so at the end i decide tu use another extension named SimpleR that works so well, perhaps it has some limitations, i don't know, but it fullfill my needs
Greetings
Diego

Reply all
Reply to author
Forward
0 new messages