Learn How To Write Programs In Java With Greenfoot

greenfoot intro   Learn How To Write Programs In Java With GreenfootIf you use your computer at a higher level, you may have wondered exactly how to write computer programs and what happens while you write certain code. However, to get a good base with quick visual results after only a little fiddling around is very hard if you start from scratch. Even if you do start from scratch, some programming languages make it harder to start getting visual results than others (aside from the very downright basics).

However, Greenfoot takes care of this problem by providing a developing platform, meant for educational purposes, where users can quickly get started and get visual results back in the form of graphics.

Greenfoot runs and uses Java for its programming language, which runs on virtually every operating system without having to re-compile for each operating system.

As I said, Greenfoot is meant to be used in educational environments, though anyone can use it to learn about the language at their own pace. I myself got introduced to the program in my Computer Science course, and so far I’ve learned a lot by using Greenfoot. Note that this program does not actually teach you Java, but instead allows you to easily change the code yourself and see what happens when you do so. Documentation is, of course, provided.

Download and Install

To get started, head to their website and download a copy for your operating system. For the first three options, you should be able to install it as you would install any other program. If you had to choose the “other systems” option, you’ll have to install it by launching the .jar file as an executable. If you run Linux, make sure it has executable rights, then put

java -jar /path/to/file

into your terminal and hit enter. If you use a form of BSD-UNIX, such as FreeBSD, the previous command may not work, so please check what command works for you. Once the installer launches, install to wherever you like, and then launch the executable file in the new folder to run Greenfoot.

Getting Started

greenfoot welcome   Learn How To Write Programs In Java With Greenfoot

When you start Greenfoot, you’ll be greeted by a welcome dialog. If you’ve never used Greenfoot before, I suggest you choose the tutorial scenario. Your browser will then open the tutorial and Greenfoot will launch the tutorial scenario, named “Wombats”.

greenfoot scenario   Learn How To Write Programs In Java With Greenfoot

Features

From there, you can left click on the classes in the right pane and choose whether to add them to the world (by selecting the option and then selecting the cell to put the object into), or whether to open and edit the source code. The code editor carries a couple nice features, including “go to line number”, a location finder on the right side, and background colors to determine which chunks of code go together.

greenfoot editor   Learn How To Write Programs In Java With Greenfoot

When you feel ready to try it out, add some objects to the world and hit “Run”. You’ll see how your objects behave and learn from the code that makes those objects behave in that way. Note that the tutorial scenario will work out-of-the-box, and adjustments to the provided code are not necessary to get it working.

greenfoot running   Learn How To Write Programs In Java With Greenfoot

Getting Help

You can also get help from the community or look at other scenarios at the Greenfoot Gallery. If you try out Greenfoot, I highly advise that you visit the website as well to get a better understanding of what Greenfoot is capable of.

Conclusion

That’s all there is! The rest is up to your imagination, and what you wish to do with it. Remember that you can get help at the Greenfoot Gallery, and definitely check out the documentation for what methods (a series of commands in code that can be called with a simple statement) in the tutorial scenario do and what the provided Greenfoot methods can add. If you need inspiration, check out the Gallery. Some of the projects on there have the source code ready for you to download and study, which is another great technique for learning Java.

How interested are you in learning to write programs? Do you think Greenfoot is a great way to get started? Will you use it to get introduced to Java? Let us know in the comments!

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

2 Comments -

0 votes

Bakari

Looks interesting, Danny. Thanks for reviewing this. I might give it a try.

0 votes

Danny Stieben

No problem. The only thing I wish out of the project is that it keeps working on features, and maybe someone will fork it and turn it into a tool that actually teaches rather than just a program used to teach with.