What is Greenfoot?
Greenfoot teaches object orientation with Java. Create "actors" which live in "worlds" to build games, simulations, and other graphical programs. Greenfoot is visual and interactive. Visualisation and interaction tools are built into the environment. The actors are programmed in standard textual Java code, providing a combination of programming experience in a traditional text-based language with visual execution. The interface is a full IDE which includes project management, auto-completion, syntax highlighting, and other tools common to most IDEs. It also allows you to publish your work both on and offline. However the interface is designed to be simple and easy to use; built with beginners in mind. Greenfoot is used by thousands of institutions around the world. It provides easy transition into other environments, such as BlueJ and more professional IDEs. Greenfoot programs are written in standard Java, one of the primary languages in academia and industry. Concepts learned transfer directly to programming in subsequent environments. Greenfoot makes the environment easy enough to use for beginners, and Java makes it powerful enough to write impressive, flexible and sophisticated applications.

System requirements
  • Minimum SDK 1.6.0 Build 22 GA (2011-06-27)


Greenfoot on an eComStation machine with Open JDK


Installing Greenfoot
Download Greenfoot-generic-242.jar (9.647Kb). Make a new directory/folder with the name "greenfoot" or something you like. Copy the file to the new created directory/folder. The copied file is an installer file, so you need first to install it. The commandfile which does the job is included in the zipfile at the end of this page. The contents of greenfoot-installer.cmd are;
@echo off
set BEGINLIBPATH=[drive: java]\JAVA160\bin
set path=[drive: java]\JAVA160\bin
set CLASSPATH=
[drive: greenfoot]
cd [drive: greenfoot]\greenfoot
java -Duser.home=[drive: greenfoot]\greenfoot -jar Greenfoot-generic-242.jar 2>greenfoot-bugs.txt
I use 2 separate directories/folders, one for Java and one for Greenfoot with the files created by this program. The references used in the cmd file;

  • [drive: java] = drive with Java (this has to be the Java from the SDK and NOT the JRE!!!, that's why the different directory/folder name.)
  • [drive: greenfoot] = drive with Greenfoot

should be replaced with real drive letters. Save your version of the file "greenfoot-installer.cmd". This file is copied to the "greenfoot" directory/folder. Furthermore, different paths?, adjust according to your needs. If you start the installation, you have to answer some questions about in which drive is Java and where to install the program. Greenfoot-generic-242.jar is the last version we can use. Next version needs Java 8, probably caused by the use of BlueJ which needs for the last versions also Java 8 minimum.

The cmd file
The program works with OpenJDK in OS/2-eCS. I have a greenfoot.cmd file with the following contents;
@echo off
set BEGINLIBPATH=[drive: java]\JAVA160\bin
set path=[drive: java]\JAVA160\bin
set CLASSPATH=
set APPBASE=[drive: greenfoot]\greenfoot
set JAVAPATH=[drive: java]\JAVA160
[drive: greenfoot]
cd [drive: greenfoot]\greenfoot
java -Duser.home=[drive: greenfoot]\greenfoot -Xms64m -Xmx256m
-cp [drive: greenfoot]\greenfoot\lib\bluej.jar;[drive: java]\JAVA160\lib\tools.jar
bluej.Boot -greenfoot=true -bluej.compiler.showunchecked=false %1 2>greenfoot-bugs.txt
The line beginning with "java ...." is broken into three lines for the sole purpose of this page. The lines "java..." and "-cp ..." and "bluej.Boot..." are one line. Mind the spaces between the commands. I use 2 separate directories/folders, one for Java and one for Greenfoot with the files created by this program. The references used in the cmd file;

  • [drive: java] = drive with the developer version (SDK) of Java
  • [drive: greenfoot] = drive with Greenfoot

should be replaced with real drive letters. Edit and save the file with a name of your choice or use the file from the distribution. This file is copied to the "greenfoot" folder (directory). Furthermore, different paths?, adjust according to your needs.

Parameters / options explained
  • The statement "-Duser.home=[drive: greenfoot]\greenfoot" will ensure that Greenfoot will save all necessary files in own directory instead of saving them in the home directory.
  • The "-Xms64m" specify the initial size of the memory allocation pool. Without Greenfoot can crash at start.
  • The "-Xmx256m" indicates the maximum limit of the used memory. Without Greenfoot can crash at start.
  • The line "-cp..." up to "-bluej.compiler.showunchecked=false" comes from the installer and are found in the Linux file.
  • The addition "2>greenfoot-bugs.txt" ensures that errors are saved in the file "greenfoot-bugs.txt". The 2 in "2>" is not a typo!

Running the program
Be sure to read the "[drive: greenfoot]\greenfoot\tutorial\tutorial.html" file. You learn how to use the tutorial files. As usual help doesn 't work. Every command which need a browser will end in "error=2" error, in other words can't start the browser. Greenfoot will almost close completely if you swith from one scenario to an other. But at the background its started all over and it will popup with a new screen. Despite the specification of memory, it sometimes happens that the startup ends in a crash with a hs_err_pidxxx.log file. I think this has to do with an error in our Java version.


Greenfoot tutorial on an eComStation machine with Open JDK


Download
In the file you can find the above command files (all driveletters are set to Q:!) and a Greenfoot icon: greenfoot-ecs.zip.

revision August 27, 2018