Book Image

Java 9 Programming Blueprints

By : Jason Lee
Book Image

Java 9 Programming Blueprints

By: Jason Lee

Overview of this book

Java is a powerful language that has applications in a wide variety of fields. From playing games on your computer to performing banking transactions, Java is at the heart of everything. The book starts by unveiling the new features of Java 9 and quickly walks you through the building blocks that form the basis of writing applications. There are 10 comprehensive projects in the book that will showcase the various features of Java 9. You will learn to build an email filter that separates spam messages from all your inboxes, a social media aggregator app that will help you efficiently track various feeds, and a microservice for a client/server note application, to name a few. The book covers various libraries and frameworks in these projects, and also introduces a few more frameworks that complement and extend the Java SDK. Through the course of building applications, this book will not only help you get to grips with the various features of Java 9, but will also teach you how to design and prototype professional-grade applications with performance and security considerations.
Table of Contents (19 chapters)
Title Page
About the Author
About the Reviewer
Customer Feedback
Taking Notes with Monumentum


The world has been waiting for Java 9 for a long time. More specifically, we've been waiting for the Java Platform Module System, and Java 9 is finally going to deliver it. If all goes as planned, we'll finally have true isolation, giving us, potentially, smaller JDKs and more stable applications. That's not all that Java 9 is offering of course; there is a plethora of great changes in the release, but that's certainly the most exciting. That said, this book is not a book about the module system. There are plenty of excellent resources that can give you a deep dive into the Java Platform Module System and its many implications. This book, though, is a much more practical look at Java 9. Rather than discussing the minutiae of the release, as satisfying as that can be, what we'll do over the next few hundred pages is look at different ways all of the great changes in recent JDK releases--especially Java 9--can be applied in practical ways.

When we're done, you'll have ten different projects that cover a myriad of problem areas, from which you can draw usable examples as you work to solve your own unique challenges.

What this book covers

Chapter 1, Introduction, gives a quick overview of the new features in Java 9, and also covers some of the major features of Java 7 and 8 as well, setting the stage for what we'll be using in later chapters.

Chapter 2, Managing Process in Java, builds a simple process management application (akin to Unix's top command), as we explore the new OS process management API changes in Java 9.

Chapter 3, Duplicate File Finder, demonstrates the use of the New File I/O APIs in an application, both command line and GUI, that will search for and identify duplicate files. Technologies such as file hashing, streams, and JavaFX are heavily used.

Chapter 4, Date Calculator, shows a library and command-line tool to perform date calculations. We will see Java 8's Date/Time API exercised heavily.

Chapter 5, Sunago - A Social Media Aggregator, shows how one can integrate with third-party systems to build an aggregator. We'll work with REST APIs, JavaFX, and pluggable application architectures.

Chapter 6, Sunago - An Android Port, sees us return to our application from Chapter 5, Sunago - A Social Media Aggregator.

Chapter 7, Email and Spam Management with MailFilter, builds a mail filtering application, explaining how the various email protocols work, then demonstrates how to interact with emails using the standard Java email API--JavaMail.

Chapter 8, Photo Management with PhotoBeans, takes us in a completely different direction when we build a photo management application using the NetBeans Rich Client Platform.

Chapter 9, Taking Notes with Monumentum, holds yet another new direction. In this chapter, we build an application--and microservice--that offers web-based note-taking similar to several popular commercial offerings.

Chapter 10, Serverless Java, moves us into the cloud as we build a Function as a Service system in Java to send email and SMS-based notifications.

Chapter 11, DeskDroid - A Desktop Client for Your Android Phone, demonstrates a simple approach for a desktop client to interact with an Android device as we build an application to view and send text messages from our desktop.

Chapter 12, What's Next?, discusses what the future might hold for Java, and also touches upon two recent challengers to Java's preeminence on the JVM--Ceylon and Kotlin.

What you need for this book

You need the Java Development Kit (JDK) 9, NetBeans 8.2 or newer, and Maven 3.0 or newer. Some chapters will require additional software, including Scene Builder from Gluon and Android Studio.

Who this book is for

This book is for beginner to intermediate developers who are interested in seeing new and varied APIs and programming techniques applied in practical examples. Deep understanding of Java is not required, but a basic familiarity with the language and its ecosystem, build tools, and so on is assumed.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "The Java architects have introduced a new file,, similar to the existing file, found at the root of the module, for example at src/main/java/"

A block of code is set as follows:

    module {

Any command-line input or output is written as follows:

$ mvn -Puber install

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "In the New Project window, we select Maven then NetBeans Application."


Warnings or important notes appear like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at We also have other code bundles from our rich catalog of books and videos available at Check them out!

Downloading the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.