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.

Codecademy: Learn Java

Location: Codecademy website
Price: £20 per month

 Codecademy: Learn Java

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

 Introduction to Programming with Greenfoot

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

 eDX

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

 Java, A Beginner’s Guide

Java, A Beginner’s Guide

Written by Java guru Herbert Schildt and published by Oracle Press, this feels to us like the closest thing to an official guide.

Thinking in Java

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.

Head First Java

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

 Java API

Java API

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

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.

W3Schools

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.

From The MagPi store

Subscribe

Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.