Applets

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

Making and Displaying Applets

You can create applets by choosing the Save As Applet option from the File Menu. If your model is not saved in it's current state you will be prompted to save it again, you will also be prompted to have an html file.

For applets to work, the html file, your model file, and the file NetLogoLite.jar must all be in the same directory. (You can copy NetLogoLite.jar from the directory where you installed NetLogo.)

Applets can read and write files on the web server. If your applet requires additional files, files it reads from, imported images, etc. You will also need to upload those files to the server. These files should appear in the same directory configuration 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 and NetLogoLite.jar must be readable by the web server user.

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.

If NetLogoLite.jar 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 NetLogoLite.jar 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 1.4.1 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 users, note that Mac OS X 10.2 and 10.3 had a fairly low memory limit for Java applets, namely 64 megabytes. Historically Mac OS X 10.4 had the same limit, but a recent Java update raised it to 96 megabytes. You can get the Java update from Apple through Software Update. Mac OS X 10.5 will presumably have the higher limit as well.

If your browser is using the browser plug-in that comes with the Sun 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".

Extensions

Many extensions can be used in applets, simply upload the directory containing the extension jar into the same directory as the model.

Extensions that require additional external jars don't work from applets. This includes the sound and gogo extensions.

Known Issues