Skip to content
Aaron Brandes edited this page Oct 13, 2022 · 5 revisions

In order to do development of NetLogo and NetLogo extensions on Windows 7/8/10, you'll need to have git, sbt and a Java 17 JDK installed. You'll also need some environment variables set correctly.

Steps for setting up Windows 7/8/10 for NetLogo and NetLogo extensions development:

Tools

The Scala Build Tool, abbreviated sbt, allows you to build NetLogo or NetLogo extensions. The Java JDK contains the Java compiler, javac.exe, which turns NetLogo source code into code that Java can execute. Git is a utility for managing source code in local and remote repositories; it enables tracking changes to a code repository and sharing changes between users (in our case, through Github).

  • Download and install git. https://git-scm.com/download/win
  • Download and install a Java JDK from Oracle (current desktop must use Java 8). http://www.oracle.com/technetwork/java/javase/downloads/index.html
  • Download and install sbt. https://www.scala-sbt.org/download.html
  • Open a console
    • Good console choices are PowerShell (usually pre-installed on Windows) or ConEmu. I do not recommend Git Bash or any other MinGW or Cygwin-based alternative, as you'll probably have path issues.
    • Make sure git is available by running git --version - you should see the version you installed.
    • Make sure sbt is available by running sbt sbtVersion - you should see the version you installed.
    • Make sure java and javac are available by running java -version and javac -version - you should see the version you installed. If not, you'll need to update your PATH user environment variable to point to the bin folder of your JDK install location (see below).

Environment Variables

Environment variables are just simple settings that are available in your console, and also to programs that you run (like sbt).

To set a user's environment variable in Windows 7, right click on My Computer -> Properties -> Advanced -> Environment Variables. There you can add a New... variable for JAVA_HOME, JAVA_OPTS and Edit... the PATH if you need to.

To set an environment variable in Windows 8 or 10 it should be the same steps. You can search for "Environment Variables" in the search bar to open the editor.

  • Add a JAVA_HOME user environment variable to points to your JDK17 installation (not the bin folder, the root of the install), as well.
    • If you see a "native2ascii not found" error when running sbt, this is probably the step you were missing. Note you have to close and re-open your console to get the new value.
    • In ConEmu or the Command Prompt, use echo %JAVA_HOME% to confirm it is set correctly, in PowerShell use $env:JAVA_HOME.

There are some extra settings that may be necessary in order for sbt and Java to compile NetLogo, increasing available memory and disabling some runtime features that slow compilation way down. The sbt.bat file that comes with sbt will look for settings in the JAVA_OPTS environment variable.

  • Add a JAVA_OPTS user environment variable with a value of -Xmx2048M -Xss10M -XX:+UseParallelGC -Dfile.encoding=UTF-8 -Dsbt.log.format=true -Dsbt.io.jdktimestamps=true
    • In ConEmu or the Command Prompt, use echo %JAVA_OPTS% to confirm it is set correctly, in PowerShell use $env:JAVA_OPTS.

If you do not want to use these settings for all sbt projects, you can instead setup your own batch file or PowerShell script to set this variable before running sbt.bat for NetLogo development only.

Running sbt.bat for NetLogo

You don't need to do the below if you are developing an extension, but it isn't a bad idea to have a local clone of NetLogo setup for easy extension testing. It will also confirm your development environment is ready to work.

  • Open your console again.
  • From the directory you want to store the NetLogo project, clone the NetLogo repository, git clone https://github.com/NetLogo/NetLogo.
  • Run git submodule update to make sure all of NetLogo's submodules are updated.
  • Now running sbt.bat in the NetLogo repository should get things started.
  • Once sbt is loaded, try running all. This is only necessary on a new clone/setup of NetLogo.
  • Once it's done, restart sbt (exit to exit), and then you can execute netlogo/run to see if it can compile and run the NetLogo GUI (it'll take some time). If NetLogo starts up, congratulations, you're ready to go!
Clone this wiki locally