Applets

NetLogo models can be run as Java applets inside a web browser.

Making an applet

You can make a model into an applet by choosing Save As Applet on NetLogo's File menu. If your model has unsaved changes you will first be prompted to save it. Then you will also be prompted to save an HTML file containing the applet.

For applets to work, the HTML file, your model file (ending in .nlogo), and the files NetLogoLite.jar and NetLogoLite.jar.pack.gz must all be in the same folder. (You can copy NetLogoLite.jar and NetLogoLite.jar.pack.gz from the folder where you installed NetLogo.)

On some systems, you can test the applet locally on your computer before uploading it to a web server. It doesn't work on all systems, though, so if it doesn't work from your hard drive, please try uploading it to a web server.

You don't need to include everything in the html file in your page. If you want, you can just take the HTML code beginning with <applet> and ending with </applet>, and paste it into any HTML file you want. It's even OK to put multiple <applet> tags on a single page.

Additional files

Applets can read files on the web server. If your applet requires additional files, such as text files it reads, images it imports, and so on, you will also need to put those files in the same folder. These files should appear in the same location relative to the model file as they appear on your computer. Applets cannot read or write files on the user's computer, only the web server. Applets cannot browse web server or the user's computer, meaning, that user-file and user-new-file do nothing in an applet. All files required to run your model including the model file itself, NetLogoLite.jar, and NetLogoLite.jar.pack.gz must be readable by the web server user.

Extensions

Many extensions can be used in applets. Simply place the folder containing the extension jar in the same folder as the model.

Extensions that require native libraries don't work from applets. This includes the QTJ and GoGo extensions.

Using an alternate jar location

If the NetLogoLite files and your model are in different directories, you must modify the archive= and value= lines in the HTML code to point to their actual locations. (For example, if you have multiple applets in different directories on the same web server, you may want to put a single copy of the NetLogoLite files in one central place and change the archive= lines of all the HTML files to point to that one central copy. This will save disk space for you and download time for your users.)

Java requirements

Getting the right version

Current versions of NetLogo require that your web browser support Java 5 or higher. Here's how to get the right Java:

If you think you have the right browser and plugin, but it still doesn't work, check your browser's preferences to make sure that Java is enabled.

The following web site may be helpful for figuring out what Java you have and getting the right version running: http://www.javatester.org/.

Increasing the available memory

Some NetLogo applets may require more memory than the browser normally makes available. This may happen if you have large numbers of agents. On Windows, you can increase the available memory ("heap") space in the Java Control Panel's applet runtime settings.

Mac OS X 10.4 users, note that Mac OS X 10.4 initially had a rather low memory limit for Java applets, namely 64 megabytes. Eventually a Java update from Apple raised it to 96 megabytes. You can get the update through Software Update.

If your browser is using the browser plug-in that comes with the Oracle JDK or JRE then instructions for starting the Java Plug-In Control Panel are available here. In the Advanced tab of the Control Panel add the following to the Java Runtime Parameters field: "-Xmx1024m".

Features not supported in applets

Note to extension authors

We recommend that you document whether your extension works in applets.

One reason an extension might fail to work is that the NetLogo build process uses ProGuard aggressively to reduce the size of NetLogoLite.jar. This can break some extensions, but often the problem is trivially fixable by adding an entry to the project/proguard/lite.txt file in the NetLogo build. If you discover that something your extension does works if you substitute NetLogo.jar, but doesn't work with NetLogoLite.jar, the NetLogo development team may be able to help you resolve the issue, if you ask about it on netlogo-devel.