1

Can someone render assistance with invoking net logo on Windows. This works on Linux fine, but taking the example code from (https://github.com/NetLogo/NetLogo/wiki/Controlling-API) I get the following. It initially appears to be something with the java CLASSPATH but that is solved with the -cp arg, why it cannot pick from the environemnt I do not understand, but then I cannot run it. Please help.

c:\Program Files\NetLogo 5.3.1\app>echo %CLASSPATH%

"C:\Program Files\NetLogo 5.3.1\app\NetLogo.jar;."

c:\Program Files\NetLogo 5.3.1\app>javac \Users\robert\Documents\example1.java
\Users\robert\Documents\example1.java:1: error: package org.nlogo.app does not e
xistimport org.nlogo.app.App;
                    ^
\Users\robert\Documents\example1.java:4: error: cannot find symbol
    App.main(argv);
    ^
  symbol:   variable App
  location: class Example1
\Users\robert\Documents\example1.java:10: error: cannot find symbol
              App.app().open(
              ^
  symbol: variable App

\Users\robert\Documents\example1.java:17: error: cannot find symbol
      App.app().command("set density 62");
      ^
  symbol:   variable App
  location: class Example1

\Users\robert\Documents\example1.java:18: error: cannot find symbol
      App.app().command("random-seed 0");
      ^
  symbol:   variable App
  location: class Example1
\Users\robert\Documents\example1.java:19: error: cannot find symbol
      App.app().command("setup");
      ^
  symbol:   variable App
  location: class Example1

\Users\robert\Documents\example1.java:20: error: cannot find symbol
      App.app().command("repeat 50 [ go ]");
      ^
  symbol:   variable App
  location: class Example1

\Users\robert\Documents\example1.java:22: error: cannot find symbol
        App.app().report("burned-trees"));
        ^
  symbol:   variable App
  location: class Example1

8 errors

Finally passing the class path as an arg gets it to complile.

c:\Program Files\NetLogo 5.3.1\app>javac -cp %CLASSPATH% \Users\robert\Documents
\example1.java

But running produces more errors.

c:\Program Files\NetLogo 5.3.1\app>java \Users\robert\Documents\Example1.java
Fel: Kan inte hitta eller kan inte ladda huvudklassen \Users\robert\Documents\Ex
ample1.java
Robert
  • 11
  • 2
  • Note that 'Fel: Kan inte hitta eller kan inte ladda huvudklassen' meand it cannot find the main class. – Robert Mar 30 '20 at 11:23
  • You don't run a Java program with `java Foo.java`. After compiling it, you run it with e.g. `java Foo` (or `java my.package.Foo`, if the code is in a package). – Seth Tisue Mar 30 '20 at 18:07
  • even running without the java extension yeails the same c:\Program Files\NetLogo 5.3.1\app>java \Users\robert\Documents\example1 Fel: Kan inte hitta eller kan inte ladda huvudklassen \Users\robert\Documents\ex ample1 – Robert Mar 31 '20 at 08:34
  • c:\Program Files\NetLogo 5.3.1\app>dir \Users\robert\Documents\examp* Volymen i enhet C har etiketten OS Volymens serienummer är 42B2-198F Innehåll i katalogen c:\Users\robert\Documents 2020-03-30 13:01 653 Example1$1.class 2020-03-30 13:01 997 Example1.class 2020-03-29 21:41 706 Example1.java 3 fil(er) 2 356 byte 0 katalog(er) 48 263 217 152 byte ledigt – Robert Mar 31 '20 at 08:35
  • 1
    `java \Users\robert\Documents\example1` is wrong, you it's just `java example1`, with the right classpath (`java -classpath ... example`). It expects a class name, not a path on the filesystem. The filesystem aspect is handled in the classpath. (And note that none of this is NetLogo-specific; this just how Java works in general.) – Seth Tisue Mar 31 '20 at 16:38

0 Answers0