Download the instructions properly formatted
Right-click onto the images and select "Open Image in new tab" to show images or use the linked PDF above
The right side of the window should now look something like this:
Give the library a better name like "Greenfoot" and press "OK".
--------------------------------------------------------------------------------------
Create another new file named "project.greenfoot" in the "src" folder. You don't need to write anything here, Greenfoot will do this itself. We just create this file so that you can later double-click it from the file explorer to open the project.
Now, your project tree should look like this:
--------------------------------------------------------------------------------------
Finally, press "Apply". Your window should look like this:
Press "OK".
--------------------------------------------------------------------------------------
Introduction
This short tutorial will guide you to create and run your first Greenfoot project right out of IntelliJ IDEA. There are plenty of advantages in doing so:- You get to use all the features of IntelliJ, especially code highlighting, auto completion and access to documentation of Greenfoot and the Java libraries
- You can take a look into the sources of Greenfoot and see how it is coded itself
- Be more flexible with your programming style, use packages, Java internal classes, and similar
- Make use of advanced programming features, like debugging or using build tools like Maven to use and create 3rd party libraries
- Many more...
Step 0 - Installing the neccecary programs
You will need to install both Greenfoot and IntelliJ IDEA. For IntelliJ, both the Community and the Ultimate version will work, but Community is free. Note though that as a student you can also get access to the Ultimate version for free. For Greenfoot, you also need to download the source code. The Greenfoot sources are available on the Greenfoot website, but it's quite complicated to order the files in the folder you get, and also some files are missing. I've created a sorted collection of all the files you need. The sources in that are for Greenfoot versions 3.6.X and 3.7.X, if you use a different version you will *also* have to get the corresponding sources from the Greenfoot website (you still also need my files).- Greenfoot Application
- Combined Greenfoot sources
- Greenfoot source code (only non 3.6.X and 3.7.X versions)
- IntelliJ IDEA
Step 1 - Create a new project in IntelliJ
After installing, launch IntelliJ and select "New Project". If you already had a project open before, you may go to "File > Close Project" (not Exit!) or create a new project directly via "File > New > Project". On the left, select "Java". Open the "Project SDK..." context menu. If you see an option "~\Greenfoot\jdk" listed under detected SKDs, select it. Otherwise, select "Add JDK...", browse to your Greenfoot installation and select the "jdk" directory. Select "Next" twice. Now give your project a name and specify its location. Finally, select "Finish". You should now see a window similar to this: --------------------------------------------------------------------------------------Step 2 - Setup Greenfoot dependencies (only once)
Select "File > Project Structure... > Global Libraries > + > Java" and navigate to your Greenfoot installation. Select the "lib" folder and choose the following options: Select "OK" and if you are being asked to add the stuff to modules, also press "OK". Use the right "+" button to also add these directories / files:- "<Greenfoot installation>/lib/extensions" - "<Greenfoot installation>/lib/javafx/lib" - "<Greenfoot installation>/lib/stylesheets" (As: Classes) - "<Combined sources>/sources" - "<Combined sources>/threadchecker.jar"
Step 3 - Add the Greenfoot library to your project
Select "File > Project Structure... > Global Libraries" and right-click onto the library you created. Select "Add to Modules..." and select "OK". Select "OK" again to save the changes and close the project structure settings. If you just created the library as in step 2 and got asked whether it should be added to the modules you don't have to do this step and the "Add to Modules..." option will not show up. --------------------------------------------------------------------------------------Step 4 - Add Greenfoot project files
Right-click onto the "src" folder and select "New > File". Name the file "standalone.properties" and paste the following code into it:main.class= controls.pause.button=Pause controls.run.button=Start run.once=Run reset.world=Reset controls.speed.label=Simulation Speed: scenario.hideControls=false controls.speedSlider.tooltip=Adjusts the execution framerate controls.pause.shortDescription=Pause the simulation. project.name=Greenfoot scenario made in IntelliJ IDEA controls.run.longDescription=Run the simulation until stopped. controls.reset.longDescription=Instantiate a new world. scenario.viewer.appletInfo= scenario.lock=false controls.pause.longDescription=Pause the simulation, leaving it in the current state. run.simulation=Run pause.simulation=Pause scenario.fullScreen=false controls.reset.shortDescription=Reset the scenario. controls.run.shortDescription=Start the simulation. controls.runonce.longDescription=Call 'act' once for every actor in the current world. controls.runonce.shortDescription=Call 'act' once for every actor in the current world. user.name=YourNameHere
Step 5 - Create launch configuration
In the top right, select "Add Configuration...". Select "Add new... > Application" and give the configuration a proper name like "Run Scenario". In "Main Class", enter "greenfoot.export.GreenfootScenarioApplication". Select "Modify options > Add VM options". In the text field "VM options" write the following, replacing "<Greenfoot installation>" with the path to your Greenfoot installation folder (the "Greenfoot" folder, not the folder it is in):--module-path="<Greenfoot installation>\lib\javafx\lib" --add-modules=javafx.controls,javafx.fxml