This site requires JavaScript, please enable it in your browser!
Greenfoot back

Greenfoot and Netbeans

You can now open and run Greenfoot projects on Netbeans.

The process is composed by three easy steps:

1. Creating a Netbeans project with your Greenfoot scenario

To create a Netbeans peoject using your Greenfoot scenario, you first need to create a new project. Select "File->New Project", then select "Java Project with Existing Sources"

add any name for this project, then press "Next". Now you need to click on "Add Folder" on "Source Package Folders" and inform your greenfoot project folder: eg:"/home/me/greenfoot/scenarios/LTA"

2. Adding Greenfoot libraries

For the project to be properly compiled and used by Netbeans, we need to add the Greenfoot libraries. To do so, right-click on the Netbeans project and select "Properties"

Go to Libraries, then click on "add JAR/Folder" and add the following jars:

  1. /usr/bin/greenfoot/lib/bluejcore.jar
  2. /usr/bin/greenfoot/lib/extensions/greenfoot.jar

Where "/usr/bin/greenfoot" is the folder where Greenfoot is installed. It may be different in your machine.

3. Configuring the project to run the Greenfoot scenario

Still in the Project Properties window, go to "Run" and fill the following fields:

  1. Main Class: greenfoot.export.GreenfootScenarioMain
  2. Arguments: here, it takes three parameters, separated by spaces:
    1. Scenario name: in our case, LTA
    2. Name of the world class (just the name, no .class extension): in our case, Groud
    3. Path to the 'greenfoot-labels' file from the Greenfoot installation: in our case, /usr/bin/greenfoot/lib/english/greenfoot/greenfoot-labels. Remeber that "/usr/bin/greenfoot" is the folder where Greenfoot is installed. It may be different in your machine. If the path includes spaces, you need to put double quotes around it ("like this") .

Now you should be able to run your Greenfoot project in Netbeans just like any native Netbeans project!