BlueJ and Greenfoot: The best IDEs to learn Java

0
225


You say you want to learn Java. It can be a daunting language. It might even seem impenetrable if you’re a new programmer. But, you take a deep breath and resolve to give it a go. Ok, first things first: You need one of those integrated development environments (IDEs) you’ve read about. A single application in which you can edit, build, run, debug, and deploy your soon-to-be-written Java application.

Several popular, free Java IDEs are available: , , and the community edition of , for example. You choose one, download and install it, and in a very short time you realize that you now have two things to learn: Java and the IDE. Your chosen development tool is as impenetrable as the language it’s supposed to help you with.

Enter and , two IDEs very specifically designed for beginners. They are the product of a team based at King’s College in London (though team members have, at times, been affiliated with universities in Australia and Denmark). The creators of BlueJ and Greenfoot selected the feature set and interface design to not overwhelm beginners.

In fact, as Neil Brown, the lead developer explains, BlueJ’s and Greenfoot’s features are “…revealed as users come to them.” You are not thrown into the deep end of the pool. Consequently, both provide an easy introduction not only to the Java language, but to the tools and techniques needed to build applications in that language.

Learn Java with BlueJ

BlueJ first appeared in 1999, named simply Blue. At that time, it was both a development environment and a language. When Java appeared, the tool was rebuilt using Java as the language and the name was changed to BlueJ.

Editions of BlueJ exist for Linux, MacOS, and Windows. BlueJ also comes in a generic form: packaged as a JAR file so that BlueJ can be installed on any system that supports Java. The current version of BlueJ (4.2.2 at the time of this writing) requires JDK 11 or later, and as such must be run on a 64-bit operating system. Earlier, 32-bit versions exist, but they are no longer being developed.

, co-written by BlueJ creator Michael Kölling, uses BlueJ as the development environment to present a beginner’s approach to object-oriented programming in Java.

Learn Java with Greenfoot

Built on BlueJ by the same creator, Michael Kӧlling, Greenfoot is a more specialized IDE than BlueJ. While BlueJ is often used in the setting of a university-level introductory programming course, Greenfoot is targeted at younger users; as young as 14 years. To capture and hold a younger audience’s attention, Greenfoot has been crafted as a “simple Java IDE and animation framework.” Which means it’s for building games.

To understand Greenfoot, you must first learn its terminology. A Greenfoot project is a “scenario.” Every scenario has a “world,” which is your game’s playing field. It is a two-dimensional container inhabited by “actors.” Be careful here—a Greenfoot actor is not the particular sort of object-oriented, concurrent programming entity of the same name (see ). Greenfoot actors are your game’s playing-pieces.

A Greenfoot actor has attributes and methods (characteristics and behaviors). One characteristic of an actor is its appearance—the icon displayed in the world to represent that actor. Greenfoot comes with a variety of actor images to get you started, or you can create and import your own image.

Greenfoot’s visual arrangement is a mirror-image of BlueJ. Greenfoot’s main window is the world. To its right, a vertical toolbar is populated with inheritance diagrams of project classes. Typically, there are two inheritance “trees” in the toolbar, one rooted in the base World class, the other rooted in the base Actor class. Derived classes branch off these two roots.

As with BlueJ, double-clicking on a class’s icon opens its associated source in an editor window. The Greenfoot editor is identical to BlueJ’s, which is not surprising, as almost all of BlueJ is executing underneath Greenfoot. So Greenfoot’s editor has BlueJ’s scope highlighting, and Greenfoot’s debugger works exactly like BlueJ’s.

Modify a class in the editor, and its icon in the inheritance diagram is cross-hatched. This indicates that the class must be re-compiled before it can be used to instantiate an object. In addition, all objects in the world derived from that class become blurred (no longer in sharp relief) to show that they are now out-of-date. Fortunately, as in BlueJ, you can compile classes individually.

greenfoot java ide IDG

The Greenfoot Wombats scenario—part of the Greenfoot tutorial. The inheritance diagrams on the right of the window show the World class, which is the current scenario’s playing field, and Actor classes, which are the game’s playing pieces. Notice that Greenfoot’s editor is identical to BlueJ’s.

Once you’ve instantiated an actor, you can place it in the world by dragging and dropping its icon into the world’s window-pane. Strictly speaking you don’t have to put an actor in the world before any of the actor’s methods can be called. Right-click on an actor to select a method to call. If the method requires input parameters, a dialog opens that allows you to supply the parameter.

Time must flow in the Greenfoot world for actors to have movement. But it’s a digital world, so time advances in ticks of an internal clock—an update loop. Two buttons—Act and Run—control the execution of that loop. Click the Act button, and the loop runs once. Click Run, the button becomes Pause, and the loop runs until you click the button again to stop it. These buttons are, of course, supremely useful for testing and debugging your game.

If you must suspend your scenario’s development session and you want to pick up where you left off, you can save the world (which is a lot less dramatic than it sounds). Greenfoot will capture the location and state of actors in the world, and encode that information for a method that’s called by the actors’ constructor. The upshot: Your stage reassembles itself the next time you start up the Greenfoot IDE.

During game play, what happens when two actors collide? Or something blows up? A game must have sound effects. Greenfoot can import .wav files into a scenario, and methods let you play those sounds when specific events are triggered. Nothing stops you from borrowing any of the sounds provided with the various tutorials on the Greenfoot website. But in the event you want to create your own, Greenfoot provides a built-in sound recorder. The recorder’s editing capabilities are simple but usable. It’s basically a “capture and trim” system.

Finally, if you need game ideas beyond those provided in Greenfoot’s tutorials, Greenfoot’s website is teeming with scenarios created and uploaded by users from around the world. Some can even be played online. The quality is understandably spotty, but the variety of games testify to Greenfoot’s versatility.

Stepping stones to pro Java programming

According to creator Michael Kӧlling, while BlueJ is typically used in a university’s introductory programming course, Greenfoot is suitable for use in high school. Nevertheless, regardless of your age, you can get plenty of mileage out of either IDE if you’ve just set foot on the road to Java self-education.

Beyond the already-mentioned tutorials, there is a considerable amount of supporting materials on the BlueJ and Greenfoot websites. We’ve already mentioned the BlueJ textbook; a textbook also exists for Greenfoot, . (See the websites for purchase information.)

Neither IDE is suitable for building product-ready, enterprise-level Java applications. But as introductory vehicles for anyone new to Java, they check all the boxes, and they don’t burden you with toolbar and menu complexity. They are solid, smooth stepping-stones to professional-grade Java development.

Copyright © 2020 IDG Communications, Inc.

LEAVE A REPLY