-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Raspberry Pi 3 Projects for Java Programmers
By :

In this section, we will be installing a file transfer application, installing Java, and preparing the NetBeans editor.
We will be using the Oracle JDK to run our Java applications. At the time of writing, the latest version is JDK 1.8, which all our projects will be using as a minimal version:
Download JDK
button.ARM version
to be downloaded. Although the version you will be seeing now may differ from the version mentioned in the book, the naming scheme for the download is the same in all these versions. Even though the Raspberry Pi is now based on a 64-bit architecture the OS is still 32-bit at the time of writing. This also means the version you will need to download is: jdk-8u[buildnumber]-linux-arm32-vfp-hflt.tar.gz
, which is the 32-bit version. The [buildnumber]
indicates the release build of the JDK. All projects are targeted to work on JDK8, so any build number that is at least 91
or higher should be working. At the time of writing, the JDK version used is jdk-8u91-linux-arm32-vfp-hflt.tar.gz
.Download FileZilla Client
link, the application will be downloaded.
Host
fieldpi
in the Username
fieldPassword
fieldport number 22
in the Port
field, which is the secured connectionQuickconnect
button, and when all the credentials are entered correctly we are logged in to the Raspberry Pi. On the left side in FileZilla we see the structure of our local computer, and on the right side we see the directory structure of the Raspberry Pi.We can now close FileZilla and do the final steps required to install this Java version.
Binaries
header.
putty.exe
file to download. This file does not need to be installed, so we can save this file in any location that we can easily reach. When PuTTY is downloaded, double-click it to open it so that you see something similar to the following screenshot:Host Name
field.RASPI3JAVA
without the quotes in the Saved Sessions
field and press Save
.Open
we are prompted with Login as,
where we enter the username pi
and press Enter.
command
+space
bar at the same time. This will open Spotlight Search,
where we can type terminal
without quotes and press return or Enteron the keyboard to open the terminal. Hold the option
button while clicking on the green circle
in the top-left corner to maximize the terminal window.ssh [email protected]
The connection we make is done with ssh
, which is a small terminal application that creates a secure connection with the Raspberry Pi. We use pi
as the username where the @
character literally means at
because we log in as this user at the specified IP address. In the preceding command-line example, I have used the 192.168.1.20
IP address of my Raspberry Pi. You should replace this with the IP address you have set for yours. We are now asked to enter the password; enter the password that has been set for the user pi during the preparation.
From this point on it does not matter how we are logged in on the Raspberry Pi as the following steps are the same via Windows with PuTTY, Mac with terminal, or using the keyboard with a display attached to the Raspberry Pi. We are now presented with the CLI on the Raspberry Pi, which gives us the opportunity to unpack and install the Java package we have uploaded to the Raspberry Pi. We will place this installation in the /opt/
directory. To make this possible we first create the java
directory inside the /opt/
directory by entering the following command:
sudo mkdir /opt/java
We use the sudo
command because this directory is owned by the root
user, which is the administrator on the Raspberry Pi. The sudo
command temporarily leverages our privileges to be an administrator for the duration of the command. With mkdir /opt/java
we created the java
directory inside the /opt/
directory. Now that we have the /opt/java
directory we are going to unpack the downloaded Java archive file. We do this by entering the following command:
sudo tar -C /opt/java -xf jdk-8u91-linux-
arm32-vfp-
hflt.tar.gz
Again we have used the sudo
command to leverage our permissions. With the tar
utility we unpack the Java archive into the /opt/java
directory with the help of the -C
parameter line switch. The command line parameters -xf
tells the tar utility that we want to unpack the jdk-8u91-linux-arm32-vfp-hflt.tar.gz
file. The filename in the preceding example is the version downloaded at the time of writing. Replace 91
with the version you have downloaded.
The Linux command line has a nice way to help you enter commands, directories, and filenames. When you have entered a part of the filename pressing the Tab key will auto-complete the filename.
We can now check if the files have been extracted correctly from the downloaded Java archive. By entering the following command we should see the directory extracted from the archive:
ls -la /opt/java/
If you see the jdk1.8.0_91
directory, as shown the following screenshot, we have successfully unpacked Java. If you have a different version of the JDK, you will see a different number than 91
at the end:
Change the font size
Change margin width
Change background colour