Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Raspberry Pi 3 Projects for Java Programmers

You're reading from  Raspberry Pi 3 Projects for Java Programmers

Product type Book
Published in May 2017
Publisher Packt
ISBN-13 9781786462121
Pages 286 pages
Edition 1st Edition
Languages
Authors (3):
Rajdeep Chandra Rajdeep Chandra
John Sirach John Sirach
Profile icon John Sirach
Pradeeka Seneviratne Pradeeka Seneviratne
Profile icon Pradeeka Seneviratne
View More author details

Table of Contents (8) Chapters

Preface Setting up Your Raspberry Pi Automatic Light Switch Using Presence Detection A Social and Personal Digital Photo Frame Integrating a Real-Time IoT Dashboard Wireless Controlled Robot Building a Multipurpose IoT Controller Security Camera with Face Recognition

Building a Multipurpose IoT Controller

Raspberry Pi is great for building powerful server-based applications, configuring it to act as a web server by installing a web server such as Nginx, Apache, Jetty, or lighttpd. A web server can serve a web application to many users concurrently through a network. But unlike other traditional web applications, Raspberry Pi-hosted web applications can be used to interact with the Raspberry Pi itself, and other peripherals attached to it.

The following diagram shows a Raspberry Pi board configured as a web server with two clients connected to it through a router:

Figure 6-1: Simple Raspberry Pi client-server model

A lightweight web application can be used to interact with sensors and actuators attached to the Raspberry Pi. As an example, you could control an LED attached to a GPIO pin or display readings of a sensor attached to the I2C pins of the Raspberry Pi.

In this chapter...

Prerequisites

To build the series of projects that will be present in this chapter, you will need following things in your tool box:

  • Raspberry Pi 3 board
  • 3 mm LED
  • 220 Ohm resistor
  • Hookup wires

Preparing your Raspberry Pi board

Before going in too deep, let's prepare our Raspberry Pi board by installing the Jetty server for projects that will be discussed in this chapter.

Installing and configuring Jetty servelet engine

Jetty servlet engine is a lightweight server component that can be used to host web applications. Jetty servlet engine consumes less memory than an Apache server and it is great for saving resources on the Raspberry Pi.

You can learn more about Jetty by visiting http://www.eclipse.org/jetty/. It includes documentation, downloads, a Maven plugin, Eclipse tooling, mailing lists, Javadocs, tools, blogs, and much more that can help you to learn to use Jetty in your projects.

The following steps will guide you through installing and configuring...

Writing your first Java web application

The servlet you will be writing to control the Raspberry Pi's GPIO pin through the internet or any local area network requires a series of configurations to build and test in the Windows environment. Then you will deploy the project to the Raspberry Pi manually and run it on the Jetty server.

Creating a Maven project from Archetype

  1. Open the NetBeans IDE and from the menu bar, click on File | New Project. The New Project wizard will appear.
  2. In Choose Project (step 1), select Maven under Categoriesand Project from Archetype under Projects,as shown in Figure 6-4.
  3. Then, click the Next button to proceed:
Figure 6-4: Choose project
  1. In Maven Archetype (step 2), select maven-archetype-webapp under Known Archetypes, as shown...

Summary

In this chapter, you learned how to develop a Java web application with NetBeans to control a GPIO-connected LED through the network. You followed s series of steps to install and configure s Jetty server on both NetBeans and the Raspberry Pi. Finally, you deployed the web application, which is the .war file generated by the build process, to the Jetty server running on the Raspberry Pi.

The Chapter 7, Security Camera with Face Recognition, presents how to use OpenCV and Java with the Raspberry Pi to develop a video application with face recognition that can be used to build a security camera.

lock icon The rest of the chapter is locked
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 $15.99/month. Cancel anytime}