Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Raspberry Pi 3 Projects for Java Programmers

You're reading from   Raspberry Pi 3 Projects for Java Programmers Get the most out of your Raspberry Pi 3 with Java

Arrow left icon
Product type Paperback
Published in May 2017
Publisher Packt
ISBN-13 9781786462121
Length 286 pages
Edition 1st Edition
Languages
Arrow right icon
Authors (3):
Arrow left icon
Rajdeep Chandra Rajdeep Chandra
Author Profile Icon Rajdeep Chandra
Rajdeep Chandra
John Sirach John Sirach
Author Profile Icon John Sirach
John Sirach
Pradeeka Seneviratne Pradeeka Seneviratne
Author Profile Icon Pradeeka Seneviratne
Pradeeka Seneviratne
Arrow right icon
View More author details
Toc

Table of Contents (8) Chapters Close

Preface 1. Setting up Your Raspberry Pi FREE CHAPTER 2. Automatic Light Switch Using Presence Detection 3. A Social and Personal Digital Photo Frame 4. Integrating a Real-Time IoT Dashboard 5. Wireless Controlled Robot 6. Building a Multipurpose IoT Controller 7. Security Camera with Face Recognition

Installing and preparing the NetBeans Java editor

At this point we have installed and prepared the Raspbian Linux OS and downloaded and installed Java JDK 1.8 on the Raspberry Pi. Our final step is to install and prepare NetBeans with Java as our editor, which is also used to upload and run the applications on our Raspberry Pi. We will be using NetBeans 8.1 as a reference for installing and preparing.

If you are not used to using NetBeans; no problem, we will go step-by-step with downloading and installing and preparing the application. To install NetBeans on your computer we first need to download the correct version onto our PC or Mac. As NetBeans runs on Java, it is also available for Linux-based OSes. To get NetBeans, go to http://www.netbeans.org and press the Download link on the top right of the page. You will be redirected to the download page, where you will see three download options. As we are focused on Java SE, the first and smallest download will suffice for our projects. Press the download button for the left-most download to download the smallest version. After download is completed, we need to install it. The installation procedure is almost identical for all platforms. All platforms have their dedicated installer, and the installation instructions are linked to on the download page below the show download bundles.

When you open NetBeans for the very first time you will be presented with a welcome screen. You can set a mark in the top-right corner of this welcome screen that says Do not show this again. Otherwise it will show up every time we start up the editor. We will now configure NetBeans in such a way that we are able to write our application on our local computer, and when we want to run our code, let NetBeans upload the application to the Raspberry Pi and run it. We will be able to see all the output we normally would see when we log in on the Raspberry Pi and run the Java application in the output window of the NetBeans editor! This will speed up our projects a lot as we do not need to do any manual actions such as uploading and logging in. To make use of this very handy feature we need to configure a Remote platform. To configure the remote platform with the Raspberry Pi, we will adding it to NetBeans.

First, we will be defining the platform itself. In NetBeans, click Tools | Java Platforms. The Java platforms settings dialog will show up:

On the left bottom, click on the Add Platform button. We are now presented with a selection if we want to add a local or a Remote Java Standard Edition. We select the Remote Java Standard Edition and press Next:

We are now presented with a follow up popup were we can enter the details of the remote platform, which is installed on the Raspberry Pi. In the following screenshot, examples are filled in, which we can use for the remote platform:

We just replace the Host IP address with the address that the Raspberry Pi is reachable on. We keep the Username pi and enter the Password we set during the preparation. We set the path to the JDK installation according to the version we have installed. In the example, it is JDK1.8 build 91. Change the 91 to the build you have installed. We do not press the Create button as the directory is already there. As the working directory, we keep the /home/pi/RASPI3JAVA/, so that we know where all our projects will be placed.

Press the Finish button to have NetBeans verify the remote platform and have it download properties from the remotely installed Java version. This action will take a couple of seconds. When you see the following screen, the remote platform has been confirmed by NetBeans:

We press Close to close the dialog so we can begin with our projects.

You have been reading a chapter from
Raspberry Pi 3 Projects for Java Programmers
Published in: May 2017
Publisher: Packt
ISBN-13: 9781786462121
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image