Java 9 Cookbook

A definitive guide to learning the key concepts of modern application development in Java

Java 9 Cookbook

Mohamed Sanaulla, Nick Samoylov

A definitive guide to learning the key concepts of modern application development in Java
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781786461407
Paperback624 pages

Book Description

Java is an object-oriented programming language. It is one of the most widely accepted languages because of its design and programming features, particularly in its promise that you can write a program once and run it anywhere.

This cookbook offers a range of software development examples in simple and straightforward Java 9 code, providing step-by-step resources and time-saving methods to help you solve data problems efficiently. Starting with the installation of Java, each recipe addresses a specific problem, with a discussion that explains the solution and offers insight into how it works.

We cover major concepts such as Project Jigsaw and various tools that will enable you to modularize your applications. You will learn new features in the form of recipes that will make your applications modular, secure, and fast.

Table of Contents

Chapter 1: Installation and a Sneak Peek into Java 9
Introduction
Installing JDK 9 on Windows and setting up the PATH variable
Installing JDK 9 on Linux (Ubuntu, x64) and configuring the PATH variable
Compiling and running a Java application
New features in Java 9
Using new tools in JDK 9
Comparing JDK 8 and JDK 9
Chapter 2: Fast Track to OOP - Classes and Interfaces
Introduction
Implementing object-oriented design using classes
Using inner classes
Using inheritance and composition to make the design extensible
Coding to an interface
Creating interfaces with default and static methods
Creating interfaces with private methods
Using enums to represent constant entities
Using the @Deprecated annotation to deprecate APIs
Using HTML5 in Javadocs
Chapter 3: Modular Programming
Introduction
Using jdeps to find dependencies in a Java application
Creating a simple modular application
Creating a modular JAR
Using a module JAR with pre-JDK 9 applications
Bottom-up migration
Top-down migration
Using services to create loose coupling between consumer and provider modules
Creating a custom modular runtime image using jlink
Compiling for older platform versions
Creating multirelease JARs
Using Maven to develop a modular application
Chapter 4: Going Functional
Introduction
Understanding and creating a functional interface
Understanding lambda expressions
Using method references
Creating and invoking lambda-friendly APIs
Leveraging lambda expressions in your programs
Chapter 5: Stream Operations and Pipelines
Introduction
Using the new factory methods to create collection objects
Creating and operating on streams
Creating an operation pipeline on streams
Parallel computations on streams
Chapter 6: Database Programming
Introduction
Connecting to a database using JDBC
Setting up the tables required for DB interactions
Performing CRUD operations
Using prepared statements
Using transactions
Working with large objects
Executing stored procedures
Chapter 7: Concurrent and Multithreaded Programming
Introduction
Using the basic element of concurrency - thread
Different synchronization approaches
Immutability as a means to achieve concurrency
Using concurrent collections
Using the executor service to execute async tasks
Using fork/join to implement divide-and-conquer
Using flow to implement the publish-subscribe pattern
Chapter 8: Better Management of the OS Process
Introduction
Spawning a new process
Redirecting the process output and error streams to file
Changing the working directory of a subprocess
Setting the environment variable for a subprocess
Running shell scripts
Obtaining the process information of the current JVM
Obtaining the process information of the spawned process
Managing the spawned process
Enumerating live processes in the system
Connecting multiple processes using pipe
Managing subprocesses
Chapter 9: GUI Programming Using JavaFX
Introduction
Creating a GUI using JavaFX controls
Using the FXML markup to create a GUI
Using CSS to style elements in JavaFX
Creating a bar chart
Creating a pie chart
Creating a line chart
Creating an area chart
Creating a bubble chart
Creating a scatter chart
Embedding HTML in an application
Embedding media in an application
Adding effects to controls
Using the new TIFF I/O API to read TIFF images
Chapter 10: RESTful Web Services Using Spring Boot
Introduction
Creating a simple Spring Boot application
Interacting with the database
Creating a RESTful web service
Creating multiple profiles for Spring Boot
Deploying RESTful web services to Heroku
Containerizing the RESTful web service using Docker
Chapter 11: Networking
Introduction
Making an HTTP GET request
Making an HTTP POST request
Making an HTTP request for a protected resource
Making an asynchronous HTTP request
Making an HTTP request using Apache HttpClient
Making an HTTP request using the Unirest HTTP client library
Chapter 12: Memory Management and Debugging
Introduction
Understanding the G1 garbage collector
Unified logging for JVM
Using the new diagnostic commands for the JVM
Try with resources for better resource handling
Stack walking for improved debugging
Some best practices for better memory usage
Chapter 13: The Read-Evaluate-Print Loop (REPL) Using JShell
Introduction
Getting familiar with REPL
Navigating JShell and its commands
Evaluating code snippets
Object-oriented programming in JShell
Saving and restoring the JShell command history
Using the JShell Java API
Chapter 14: Scripting Using Oracle Nashorn
Introduction
Using the jjs command-line tool
Embedding the Oracle Nashorn engine
Invoking Java from Oracle Nashorn
Using the ES6 features implemented in Oracle Nashorn
Chapter 15: Testing
Introduction
Unit testing of an API using JUnit
Unit testing by mocking dependencies
Using fixtures to populate data for testing
Behavioral testing

What You Will Learn

  • Set up JDK and know the differences in the JDK 9 installation
  • Implement OO Designs using Classes and Interfaces
  • Manage operating system processes
  • Understand the new modular JDK and modular programming
  • Create a modular application with clear dependencies
  • Build graphical user interfaces using JavaFX
  • Use the new HTTP Client API
  • Learn about the new diagnostic features in Java 9
  • See how to use the new jShell REPL tool
  • Execute ES6-compliant JavaScript code from your Java applications

Authors

Table of Contents

Chapter 1: Installation and a Sneak Peek into Java 9
Introduction
Installing JDK 9 on Windows and setting up the PATH variable
Installing JDK 9 on Linux (Ubuntu, x64) and configuring the PATH variable
Compiling and running a Java application
New features in Java 9
Using new tools in JDK 9
Comparing JDK 8 and JDK 9
Chapter 2: Fast Track to OOP - Classes and Interfaces
Introduction
Implementing object-oriented design using classes
Using inner classes
Using inheritance and composition to make the design extensible
Coding to an interface
Creating interfaces with default and static methods
Creating interfaces with private methods
Using enums to represent constant entities
Using the @Deprecated annotation to deprecate APIs
Using HTML5 in Javadocs
Chapter 3: Modular Programming
Introduction
Using jdeps to find dependencies in a Java application
Creating a simple modular application
Creating a modular JAR
Using a module JAR with pre-JDK 9 applications
Bottom-up migration
Top-down migration
Using services to create loose coupling between consumer and provider modules
Creating a custom modular runtime image using jlink
Compiling for older platform versions
Creating multirelease JARs
Using Maven to develop a modular application
Chapter 4: Going Functional
Introduction
Understanding and creating a functional interface
Understanding lambda expressions
Using method references
Creating and invoking lambda-friendly APIs
Leveraging lambda expressions in your programs
Chapter 5: Stream Operations and Pipelines
Introduction
Using the new factory methods to create collection objects
Creating and operating on streams
Creating an operation pipeline on streams
Parallel computations on streams
Chapter 6: Database Programming
Introduction
Connecting to a database using JDBC
Setting up the tables required for DB interactions
Performing CRUD operations
Using prepared statements
Using transactions
Working with large objects
Executing stored procedures
Chapter 7: Concurrent and Multithreaded Programming
Introduction
Using the basic element of concurrency - thread
Different synchronization approaches
Immutability as a means to achieve concurrency
Using concurrent collections
Using the executor service to execute async tasks
Using fork/join to implement divide-and-conquer
Using flow to implement the publish-subscribe pattern
Chapter 8: Better Management of the OS Process
Introduction
Spawning a new process
Redirecting the process output and error streams to file
Changing the working directory of a subprocess
Setting the environment variable for a subprocess
Running shell scripts
Obtaining the process information of the current JVM
Obtaining the process information of the spawned process
Managing the spawned process
Enumerating live processes in the system
Connecting multiple processes using pipe
Managing subprocesses
Chapter 9: GUI Programming Using JavaFX
Introduction
Creating a GUI using JavaFX controls
Using the FXML markup to create a GUI
Using CSS to style elements in JavaFX
Creating a bar chart
Creating a pie chart
Creating a line chart
Creating an area chart
Creating a bubble chart
Creating a scatter chart
Embedding HTML in an application
Embedding media in an application
Adding effects to controls
Using the new TIFF I/O API to read TIFF images
Chapter 10: RESTful Web Services Using Spring Boot
Introduction
Creating a simple Spring Boot application
Interacting with the database
Creating a RESTful web service
Creating multiple profiles for Spring Boot
Deploying RESTful web services to Heroku
Containerizing the RESTful web service using Docker
Chapter 11: Networking
Introduction
Making an HTTP GET request
Making an HTTP POST request
Making an HTTP request for a protected resource
Making an asynchronous HTTP request
Making an HTTP request using Apache HttpClient
Making an HTTP request using the Unirest HTTP client library
Chapter 12: Memory Management and Debugging
Introduction
Understanding the G1 garbage collector
Unified logging for JVM
Using the new diagnostic commands for the JVM
Try with resources for better resource handling
Stack walking for improved debugging
Some best practices for better memory usage
Chapter 13: The Read-Evaluate-Print Loop (REPL) Using JShell
Introduction
Getting familiar with REPL
Navigating JShell and its commands
Evaluating code snippets
Object-oriented programming in JShell
Saving and restoring the JShell command history
Using the JShell Java API
Chapter 14: Scripting Using Oracle Nashorn
Introduction
Using the jjs command-line tool
Embedding the Oracle Nashorn engine
Invoking Java from Oracle Nashorn
Using the ES6 features implemented in Oracle Nashorn
Chapter 15: Testing
Introduction
Unit testing of an API using JUnit
Unit testing by mocking dependencies
Using fixtures to populate data for testing
Behavioral testing

Book Details

ISBN 139781786461407
Paperback624 pages
Read More

Read More Reviews

Recommended for You

Mastering Concurrency Programming with Java 8 Book Cover
Mastering Concurrency Programming with Java 8
$ 43.99
$ 30.80
Learning Java Functional Programming Book Cover
Learning Java Functional Programming
$ 43.99
$ 30.80
Learning Hadoop 2 Book Cover
Learning Hadoop 2
$ 29.99
$ 21.00
Modern Python Cookbook Book Cover
Modern Python Cookbook
$ 39.99
$ 28.00
Linux Shell Scripting Cookbook, Second Edition Book Cover
Linux Shell Scripting Cookbook, Second Edition
$ 26.99
$ 5.40
Java Deep Learning Essentials Book Cover
Java Deep Learning Essentials
$ 39.99
$ 28.00