ropensci / nlrx

nlrx NetLogo R
https://docs.ropensci.org/nlrx
GNU General Public License v3.0
77 stars 12 forks source link

The project still going? Some errors with Java and extensions #97

Closed rogerio-bio closed 4 months ago

rogerio-bio commented 7 months ago

Hi, thank you for the package @nldoc

I tried to use NetLogo 6.2.1 and encountered this error: java.lang.UnsupportedClassVersionError: org/myworldgis/netlogo/GISExtension has been compiled by a more recent version of the Java Runtime (class file version 55.0). This version of the Java Runtime only recognizes class file versions up to 52.0.

This error occurs when using solo NetLogo. Now, after switching to NetLogo 6.4.0, I encountered this error:

results <- run_nl_all(nl = nl) Exception in thread "main" Can't find extension: profiler at position 12 in at org.nlogo.core.ErrorSource.signalError(ErrorSource.scala:11)

The GIS extension only works with Java version 55.0. Could the package be updated to support newer Java and NetLogo versions?

Thank you

bitbacchus commented 7 months ago

Hi rogerio-bio,

Could the package be updated to support newer Java and NetLogo versions?

6.4.0 is the newest version, already. And it seems to work on my PC with nlrx 0.4.5. About Java, as Netlogo bundles Java normally NetLogo extentions should work with Java version that comes with NetLogo. But you can install and use your own Java if you need. There are instructions in the NetLogo docs.

Your error message says Can't find extension. Have you tried this, already https://docs.ropensci.org/nlrx/articles/furthernotes.html#netlogo-extensions ?

Best,

Sebastian

rogerio-bio commented 7 months ago

I will uninstall Java from my PC and try to use the Java included in version 6.4.0.

I'll keep you updated here.

rogerio-bio commented 7 months ago

Hi, here's what I did:

1 - I uninstalled my Java to use the one that comes with NetLogo 6.4.0, but I encountered the following error:

> results <- run_nl_all(nl = nl)

JAVA_HOME not defined, using java on PATH.
If you encounter errors, set JAVA_HOME or update your PATH to include java.exe.

2 - I installed Java and defined JAVA_HOME:

`netlogopath <- file.path("C:/Program Files/NetLogo 6.4.0")

Sys.setenv(JAVA_HOME=("C:/Program Files/Java/jdk-11"))`

Erros persist:

`> results <- run_nl_all(nl = nl)
Exception in thread "main" Can't find extension: profiler at position 12 in 
    at org.nlogo.core.ErrorSource.signalError(ErrorSource.scala:11)
    at org.nlogo.workspace.ExtensionManager.importExtension(ExtensionManager.scala:180)
    at org.nlogo.parse.StructureParser$.$anonfun$parsingWithExtensions$1(StructureParser.scala:74)
    at org.nlogo.parse.StructureParser$.$anonfun$parsingWithExtensions$1$adapted(StructureParser.scala:68)
    at scala.collection.immutable.List.foreach(List.scala:431)
    at org.nlogo.parse.StructureParser$.parsingWithExtensions(StructureParser.scala:68)
    at org.nlogo.parse.StructureParser$.parseSources(StructureParser.scala:33)
    at org.nlogo.parse.NetLogoParser.basicParse(NetLogoParser.scala:17)
    at org.nlogo.parse.NetLogoParser.basicParse$(NetLogoParser.scala:15)
    at org.nlogo.parse.FrontEnd$.basicParse(FrontEnd.scala:10)
    at org.nlogo.parse.FrontEndMain.frontEnd(FrontEnd.scala:26)
    at org.nlogo.parse.FrontEndMain.frontEnd$(FrontEnd.scala:25)
    at org.nlogo.parse.FrontEnd$.frontEnd(FrontEnd.scala:10)
    at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:47)
    at org.nlogo.compile.Compiler.compileProgram(Compiler.scala:54)
    at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:51)
    at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:535)
    at org.nlogo.headless.HeadlessWorkspace.open(HeadlessWorkspace.scala:502)
    at org.nlogo.api.Controllable.open(Controllable.scala:19)
    at org.nlogo.headless.Main$.newWorkspace$1(Main.scala:58)
    at org.nlogo.headless.Main$.runExperiment(Main.scala:67)
    at org.nlogo.headless.Main$.$anonfun$main$1(Main.scala:47)
    at org.nlogo.headless.Main$.$anonfun$main$1$adapted(Main.scala:47)
    at scala.Option.foreach(Option.scala:407)
    at org.nlogo.headless.Main$.main(Main.scala:47)
    at org.nlogo.headless.Main.main(Main.scala)`

4 - I moved the model to the app/models folder, but:

`> results <- run_nl_all(nl = nl)
Exception in thread "main" Can't find extension: profiler at position 12 in 
    at org.nlogo.core.ErrorSource.signalError(ErrorSource.scala:11)
    at org.nlogo.workspace.ExtensionManager.importExtension(ExtensionManager.scala:180)
    at org.nlogo.parse.StructureParser$.$anonfun$parsingWithExtensions$1(StructureParser.scala:74)
    at org.nlogo.parse.StructureParser$.$anonfun$parsingWithExtensions$1$adapted(StructureParser.scala:68)
    at scala.collection.immutable.List.foreach(List.scala:431)
    at org.nlogo.parse.StructureParser$.parsingWithExtensions(StructureParser.scala:68)
    at org.nlogo.parse.StructureParser$.parseSources(StructureParser.scala:33)
    at org.nlogo.parse.NetLogoParser.basicParse(NetLogoParser.scala:17)
    at org.nlogo.parse.NetLogoParser.basicParse$(NetLogoParser.scala:15)
    at org.nlogo.parse.FrontEnd$.basicParse(FrontEnd.scala:10)
    at org.nlogo.parse.FrontEndMain.frontEnd(FrontEnd.scala:26)
    at org.nlogo.parse.FrontEndMain.frontEnd$(FrontEnd.scala:25)
    at org.nlogo.parse.FrontEnd$.frontEnd(FrontEnd.scala:10)
    at org.nlogo.compile.CompilerMain$.compile(CompilerMain.scala:47)
    at org.nlogo.compile.Compiler.compileProgram(Compiler.scala:54)
    at org.nlogo.headless.HeadlessModelOpener.openFromModel(HeadlessModelOpener.scala:51)
    at org.nlogo.headless.HeadlessWorkspace.openModel(HeadlessWorkspace.scala:535)
    at org.nlogo.headless.HeadlessWorkspace.open(HeadlessWorkspace.scala:502)
    at org.nlogo.api.Controllable.open(Controllable.scala:19)
    at org.nlogo.headless.Main$.newWorkspace$1(Main.scala:58)
    at org.nlogo.headless.Main$.runExperiment(Main.scala:67)
    at org.nlogo.headless.Main$.$anonfun$main$1(Main.scala:47)
    at org.nlogo.headless.Main$.$anonfun$main$1$adapted(Main.scala:47)
    at scala.Option.foreach(Option.scala:407)
    at org.nlogo.headless.Main$.main(Main.scala:47)
    at org.nlogo.headless.Main.main(Main.scala)`

The only "solution" that worked was to run NetLogo 6.2.1 with JAVA_HOME set to JDK 11. However, with this solution, I can't run my models on NetLogo itself. Any ideas?

Polvi8 commented 6 months ago

I am experiencing the same issue with a model I made.

Just a couple of things:

  1. As far as I know, getting JAVA_HOME not defined, using java on PATH. If you encounter errors, set JAVA_HOME or update your PATH to include java.exe. is not an error itself. It is more like you are being warned that as there is no defined "JAVA_HOME" a default path to java will be used. Which I assume it is the one bundled with Netlogo.

  2. In my case, the app/models does not exist. I have NetLogo 6.4.0/app on one hand, and Netlogo 6.4.0/models on the other. However, I've tried placing my model in both (and updating the modelpah) but none worked, the csv extension still cannot be found.

I've been doing this setting the folder containing the .nlogo file for the model and other folders with varions input files. Could this be the issue?

bitbacchus commented 6 months ago

@Polvi8 you are correct with both. We haven't updated nlrx to 6.4.0, yet, it seems that we have to update the documentation then, too.

Polvi8 commented 6 months ago

Glad to know you are working on it. Thanks a lot for your work!

In the meantime, I found these solutions, do they seem viable?