Everything you need to learn Java with Raspberry Pi
By Rob Zwetsloot. Posted

It’s clunky, powerful, and divides opinion faster than Gordon Ramsay chopping an onion. It’s time to learn Java.
Advertisement
The desktop computer you've been waiting for: Raspberry Pi 500+
Codecademy: Learn Java
Location: Codecademy website
Price: £20 per month
Java isn’t like other languages, and its complex and wordy syntax can be baffling for beginners. There’s no denying its power and popularity, though.
This article first appeared in The MagPi 78 and was written by Lucy Hattersley
Claiming over 25 million users, the Codecademy website has courses (many free) on a plethora of different programming languages and tools.
Learn Java is its flagship course, but sadly not one of the free ones. You can follow some introductory lessons, but you’ll need to get the $20 a month Codecademy Pro plan to finish it.
It’s worth it, though. On Codecademy you’ll find a comprehensive stack of tutorials that cover all the basics from the Java syntax, through to creating objects and data structures.
You learn via interactive lessons that run inside the Chromium browser. The window is split into three columns: on the left is the lesson text; in the middle is a code editor; on the right is an emulated terminal. Typically you’ll find boilerplate code in the editor and have to add elements by following the instructions. Click Run and check the output in the terminal.
Codecademy is superb at hand-holding, and the web-based setup is ideal for beginners. This is especially handy given Java’s obtuse nature.
Introduction to Programming with Greenfoot
Location: Greenfoot website
Price: £86 / $102
Greenfoot is a Java IDE developed by Michael Kölling from King’s College London. On the Pi you’ll find it under Programming in the Raspbian menu.
The Greenfoot IDE creates a visual world for your Java classes to live in, much like Scratch or Blockly. Students create ‘actors’ which live in this world, and use it to build games, simulations, and other graphical programs.
This visual nature enables Greenfoot to leapfrog the abstract nature of programming, with students able to see their objects interacting in a visual manner. Its actors and worlds are coded in standard Java. So you get a good combination of standard programming and visual execution.
This book has fun projects to follow, including building a piano, simulating bubbles and leaves floating in the air, foxes and rabbits, and a simulation of the motion of stars and planets.
Make sure you download the correct project files for the Pi and its Greenfoot IDE 2.4 – they’re marked ‘Old version of book scenarios for Greenfoot 2.x’ on the book’s webpage.
edX
Location: edX website
Price: Free
If you want to take your Java learning to a professional level, check out the selection of MOOCs (massive open online courses) taking place on edX.
Intended as university-grade courses, MOOCs are challenging but rewarding and you get to share the experience with other learners online.
The Java courses are provided by a range of different institutions, including Microsoft, Red Hat, and UBC. MIT has also offered courses in the past, although none of its Java software development courses are running at the moment.
Many courses are self-paced, but some follow a strict timetable with projects and final exams. You’ll find a dedicated bunch of individuals in the forums and keen staff willing to nudge on newcomers.
The courses are definitely a challenge, and you can pay to have a verified certificate. However, you can enrol on most courses for free and often the learning is worth it regardless.
We’ve found the estimated effort to be lowballed. So be prepared to put in more hours than course providers suggest.
While edX might not be the best place to start, it’s the place to head after you’ve got some grounding in programming and want a challenge.
The best books
Written by Java guru Herbert Schildt and published by Oracle Press, this feels to us like the closest thing to an official guide.
Once you get past the nuts and bolts, it’s time to start thinking about how to improve as a programmer. Java is a useful language for thinking about coding concepts, and this book is the ideal partner for the curious coder.
If you only buy one book on Java, then make sure it’s this one. As well as covering the basics, it dives deep into esoteric concepts such as compiling and the JVM (Java Virtual Machine). All aspects of OOP are covered.
Interactive websites
The Java API is one of the best maintained set of documents in existence. Every object and class you encounter is detailed in a standardised manner.
LeetCode has a web-based Playground IDE that you can use to quickly test out Java code (along with many other languages). But it also has a bunch of articles, interviews, and opinion pieces that are fun to read.
This website is better known for its web developer support, but Java is a popular language amongst web developers so it has a comprehensive Java section. There are some neat tutorials and example Java code that is handy to have around.

Rob is amazing. He’s also the Features Editor of Raspberry Pi Official Magazine, a hobbyist maker, cosplayer, comic book writer, and extremely modest.
Subscribe to Raspberry Pi Official Magazine
Save up to 37% off the cover price and get a FREE Raspberry Pi Pico 2 W with a subscription to Raspberry Pi Official Magazine.
More articles

Raspberry Pi 500+ in Raspberry Pi Official Magazine issue 158
We’re quite taken with Raspberry Pi 500+. But when you don’t need all that processing power, and just want a board that will make a plastic skeleton jump around in a terrifying manner, you’ll find Raspberry Pi Pico more than up to the job. There’s more terror in the magazine (which is only right as […]
Read more →

Win one of five Raspberry Pi SSD 1TB
Raspberry Pi prides itself on high quality hardware, and this 1TB Raspberry Pi SSD is no different. You can use it with a standard Raspberry Pi or even in your desktop PC – the choice is yours. We have five to give away and you can enter below Win 1 of 5 Raspberry Pi SSD […]
Read more →

Dual-screen cyberdeck
Twin screens mean you can code on one screen while watching David Bowie’s 1978 Musikladen show on the other.
Read more →
Sign up to the newsletter
Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.