The Raspberry Pi is a powerful machine with many use-cases. A lot of this power is based on the operating system you use. For our “Getting Started” examples we will be using the “official Raspberry Pi OS” (formerly known as “Raspbian OS”) but there is a long list of other possibilities which is listed for example on the“Awesome Raspberry Pi” list on GitHub.
In this article we start with a brand new Raspberry Pi board.
First step: take your new Raspberry Pi out of the box of course :-)
Take a good look at it, what you are holding in your hands is a true master piece. A wonder of technical engineering with a perfect mix of powerful yet inexpensive components.
But be aware! This is also some piece of sensitive electronics. It’s always a good idea to first touch the grounding pin of a power outlet to make sure your body is not electrically charged which could damage one of the components on the board.
The SD card will hold the operating system. On the Raspberry Pi website, on the download page, you can find the Imager tool. Select the version for your computer, download and install it.
Start the Imager and follow these steps:
By selecting the “Full” edition, we will have an operating system which is preloaded with a load of additional tools, including “OpenJDK 11”, so will be able to take a quick start with Java development.
As we have put the Full edition on the SD card, Java is already available. Open a terminal window and type in java -version
.
Java will be started to show you the installed version.
$ java -version
openjdk version "11.0.9" 2020-10-20
OpenJDK Runtime Environment (build 11.0.9+11-post-Raspbian-1deb10u1)
OpenJDK Server VM (build 11.0.9+11-post-Raspbian-1deb10u1, mixed mode)
Nothing to do here! Pi4J are dependencies you add to your project with Maven or Gradle. So nothing to be installed…
If you want to get started with Pi4J V2 without creating a full Java project, take a look at the “single source file” example with JBang.
Open a terminal and perform following commands
sudo apt update
sudo apt full-upgrade
Raspberry Pi OS is based on Debian - one of the largest Linux distrubutions. When running these commands regularly, you will keep your installation up to date for the particular major Raspberry Pi OS release you are using (e.g. Debian V9, aka Stretch). It will not update from one major release to another, for example, Stretch (V9) to Buster (V10).