Installing Raspbian
To install Raspbian, we need to get the Raspberry Pi ready for use. As the Raspberry Pi has no power on and off button, the powering of the Raspberry Pi will be done as the last step:
- At the bottom of the Raspberry Pi on the side you will see a slot to insert your MicroSD card. Insert the SD card with the connectors pointing to the board.
- Next, connect the HDMI or the composite connector and your keyboard and mouse. You won't need a network cable as we will be using the wireless functionality built into the Raspberry Pi.
- We will now connect the Raspberry Pi with the micro USB power supply.
- When the Raspberry Pi boots up, you will be presented with the OSes available to be installed. Depending on the download of NOOBS you have done, you will be able to see if the Raspbian OS is already available on the SD card or if it will be installed by downloading it. This is visualized by showing an SD card image or a network image behind the OS name. In the following screenshot, you see the NOOBS installer with the Raspbian image available on the SD card.
- At the bottom of the installation screen you will find the
Language
andKeyboard
drop-down menus. Make sure you select the appropriate language and keyboard selection; otherwise, it will be difficult to enter the right characters on the command line and in other tools requiring text input.
- Select the
Raspbian [RECOMMENDED]
option and click theInstall (i)
button to start installing the OS:

- You will be prompted with a popup confirming the installation as it will overwrite any existing installed OSes. As we are using a clean SD card, we will not be overwriting any.
Note
It is safe to press Yes to start the installation. This installation will take a couple of minutes, so it is a good time to go for a second cup of coffee.
- When the installation is done you can press
Ok
in the popup that appears and the Raspberry Pi will reboot. Because Raspbian is a Linux OS, you will see text scrolling by that relates to services that are being started by the OS. - When all services are started, the Raspberry Pi will start the default graphical environment, called LXDE, which is one of the Linux window managers.
Configuring Raspbian
Now that we have installed Raspbian and have it booting into the graphical environment we can start configuring the Raspberry Pi for our purposes. To be able to configure the Raspberry Pi, the graphical environment has a utility tool installed, which eases up the configuration called Raspberry Pi Configuration:
- To open this tool, use the mouse and click on the
Menu
button on the top left, navigate toPreferences
, and press theRaspberry Pi Configuration
menu option, as shown in the following screenshot:

- When you click on the
Raspberry Pi Configuration
toolMenu
option a popup will appear with the graphical version of theraspi-config
command-line tool. In the graphical popup we see four tabs explaining different parts of possible configuration options. We first focus on the System tab, which allows us to:- Change the
Password
- Change the
Hostname
, which helps to identify the Raspberry Pi in the network - Change the
Boot
method toTo Desktop
or theCLI
- Set the
Network at Boot
option
- Change the
- With the system newly installed, the default username is
pi
and the password is set toraspberry
. Because these are the default settings, it is recommended that we change the password. - Press the
Change Password
button and enter a newly chosen password twice, Once to set the password and the second time to make sure we have entered the new password correctly. - Press
Ok
when the password has been entered twice.
Note
Try to come up with a password that contains capital letters, numbers, and some strange characters, as this will make it more difficult to guess.
- Now after we have set a new password, we are going to change the hostname of the Raspberry Pi. With the hostname we are able to identify the device on the network. I have changed the hostname into
RASPI3JAVA
, which helps me to identify the Raspberry Pi to be used for the book.
Note
The hostname is used on the CLI, so you will immediately identify this Raspberry Pi when you log in.
- By default, the Raspberry Pi boots into the graphical user interface, which you are looking at right now. Because a future project will require us to make use of a display with our application, we will be choosing to boot into CLI mode.
- Click on the
radio
button that saysTo CLI
. The next time we reboot, we will be shown the CLI. - Because we will be using the integrated Wi-Fi connection on this Raspberry Pi, we are going to change the
Network at Boot
option to have it waiting for the network. Later on in the book we will be creating network-based services and we will be logging in from remote locations. Having the network ready before any service requiring a network connection is a good practice. - Tick the box that says
Wait for network
.
We have set some default settings, which sets some primary options to help us identify the Raspberry Pi and change the boot mode. We will now be changing some advanced settings that enable us to make use of the hardware provided by the Raspberry Pi:
- Click on the
Interface
tab, which will give us a list of the available hardware provided. This list is as follows:Camera:
The Official Raspberry Pi camera interfaceSSH:
To be able to log in from remote locationsSPI:
Serial peripheral interface bus for communicating with hardwareI2C:
Serial communication bus mostly used between chipsSerial:
The serial communication interface1-Wire:
Low data power supplying bus interface conceptual based on I2CRemote GPIO
- A future project that we will be working on will require some kind of camera interface. This project will be able to use both the local attached official Raspberry Pi Camera module as well as a USB connected webcam.
- If you have the camera module, tick the
Enabled
radio box behindCamera
. We will be deploying our applications immediately from the editor. This means we need to enable theSSH
option. By default this already is, so we leave the setting as it is. If theSSH
option is not enabled, tick theEnabled
radio
button behind theSSH
option. For now, you can leave the other interfaces disabled as we will only enable them when we need them. - As we now have enabled the default interfaces that we will need, we are going to do some performance tweaking. Click on the
Performance
tab to open the performance options. - We will not need to overclock the Raspberry Pi, so you can leave this option as it is. Later on in the book we will be interfacing with the Raspberry Pi's display and doing neat tricks with it. For this, we need some memory for the Graphical Processor Unit (GPU). By default this is set to 64 MB. We will ask for the largest amount of memory possible to be assigned to the GPU, which is 512 MB. Put
512
behind theGPU Memory
option; there is no need to enter the textMB
. The memory on the Raspberry Pi is shared between the system and the GPU. Having this option set to 512 MB results in 512 MB available for the system. I can assure you that this is more than sufficient.
- Now that we are done with the system configuration, we are making sure we can work with the Raspberry Pi. Click on the
Localisation
tab to show the options applicable to the location the Raspberry Pi resides in. We have the following options:Set Locale
: Where you set your locale settingsTimezone
: The time zone you are currently inKeyboard
: The layout of the keyboardWiFi Country
: The country you will be making the Wi-Fi connection in
- This book uses the US-English language with a broad character set. Unless you prefer to continue with your own personal preferences, change the following by pressing the
Set Locale
button:Language
toen (English)
Country
toUS (USA)
Character Set
toUTF-8
- Press the
OK
button to continue.
As this needs to build up the Locale settings this can take up to about 20 seconds to set up. You will be notified with a small window when this process is finished.
- The next step is to set the timezone. This is needed as we want to have time and dates shown correctly.
- Click on the
Set Timezone
button and select your appropriateArea
andLocation
from the drop-down menus. When done, press theOK
button. - To make sure that the text we enter in any input field is correct, we are going to set the layout of our keyboard. There are a lot of layouts available, so you need to check yours. The Raspberry Pi is quite helpful and provides many keyboard options.
- Press the
Set Keyboard
button to open up a popup showing the keyboard options. Here, you are able to select your country and the keyboard layout available for this country. In my case, I have to selectUnited States
as theCountry
and theVariant
asEnglish (US, with euro on 5)
. - After you have made the selection, you can test your keyboard setup in the
input
field below theCountry
andVariant
selection lists. Press theOK
button when you are satisfied with your selection.
- Unless you are connecting your Raspberry Pi to a wired network connection, we are going to set up the country we are going to make the Wi-Fi connection in so that we are able to connect remotely to the Raspberry Pi. Press the
Set WiFi Country
button to have theWifi Country Code
shown, which provides us the list of available countries for the Wi-Fi connection. Press theOK
button after you have made the selection. We are now done with the minimal Raspberry Pi system configuration. - Press
OK
in the settings window to have all our settings stored and pressNo
in the popup that follows that says a reboot is needed to have the settings applied as, we are not completely done yet. - Our final step is to set up the local Wi-Fi chip on the Raspberry Pi.
We will now set up the Wi-Fi on the Raspberry Pi. If you want your Raspberry Pi connected with a network cable, you can skip this section and head over to the Set fixed IP
section:
- To set up the Wi-Fi, click on the
Network
icon, which is at the top of the screen between theBluetooth
andSpeaker Volume
icons. - When you click this button, the Raspberry Pi will start to scan for available wireless networks. Give it a couple of seconds if your network does not appear immediately. When you see your network appear, click on it, and if your network is secured you will be asked to supply the credentials required to be able to connect to your wireless network.
Note
If you have any trouble connecting to your wireless network without any messages, log in to your router and change the Wi-Fi channel to a channel lower than channel 11.
- When you have entered your credentials and pressed the
OK
button you will see the icon changing from the two network computers to the wireless icon, as it it trying to connect to the wireless network. - Now that the Raspberry Pi has rebooted, we have configured the wireless network to make sure the wireless network will keep its connection. As the Raspberry Pi is an embedded device targeting low power consumption, the Wi-Fi connection is possible set to sleep mode if after a specific time there is no network usage.
- To make sure the Wi-Fi does not go into power sleep mode we will be changing a setting through the command line that will make sure that this won't happen. To open a CLI we need to open a terminal. A terminal is a window that will show the command prompt where we are able to provide commands.
- When you look at the graphical interface you will notice a small
computer screen
icon at the top in the menu bar. When we hover over this icon it shows the text terminal. Press this icon to open up a terminal. - A popup will open with a large black screen showing the command prompt, as shown in the following screenshot:

Note
Do you notice the hostname we set earlier? This is the same prompt as we will see when we log in remotely.
- Now that we have a command line open we need to enter a command to make sure the wireless network will not go to sleep after a period of no network activity. Enter the following in the terminal:
sudo iw dev wlan0 set power_save off
- Press Enter. This command sets the power save mode to off so the
wlan0
(wireless device) won't enter power save mode and will stay connected to the network.
We are almost done with setting up the Raspberry Pi. To be able to connect to the Raspberry Pi from a remote location we need to know the IP address of the Raspberry Pi. This final configuration step involves setting a fixed IP address into the Raspberry Pi settings:
- To open the settings for a fixed IP configuration, we are going to open up the settings by pressing the wireless network icon with the right mouse button and press the
WiFi Networks (dhcpcdui) Settings
option. - A popup will appear with the settings we can change. As we will only change the settings of the Wi-Fi connection, we select I
nterface
next to theConfigure
option. When interface is selected, we select thewlan0
option in the drop-down menu next to the interface selection.
Note
If you have chosen to use a wired connection instead of the wireless connection you can select the eth0
option next to the interface
option.
- We now have a couple of options available to enter IP address-related information. Please refer to the documentation of your router to find out which IP address is available to you which you can use. My advice is to only enter the IP address in the available fields, which leaves the other options automatically configured, like in the following screenshot. Notice that the entered IP address is the correct one; this only applies to my configuration, which could differ from yours:

- After you have entered the IP address you can click
Apply
andClose
. - It is now time to restart our Raspberry Pi and have it boot to the Command Line Interface (CLI).
- While it is rebooting, you will see a lot of text scrolling, which shows the services starting and at the end, instead of starting, the graphical interface, we are now shown the text-based CLI, as shown in the following screenshot:

- If you want to return to the graphical interface just type in the following command:
startx
- Press Enterand wait a couple of seconds for the graphical user interface to appear again. We are now ready to install the Oracle JDK, which we will be using to run our Java applications.