Book description
Solutions for modular, functional, reactive, GUI, network, and multithreaded programming
Key Features
- Explore the latest features of Java 11 to implement efficient and reliable code
- Develop memory-efficient applications, understanding new garbage collection in Java 11
- Create restful webservices and microservices with Spring boot 2 and Docker
Book Description
For more than three decades, Java has been on the forefront of developing robust software that has helped versatile businesses meet their requirements. Being one of the most widely used programming languages in history, it's imperative for Java developers to discover effective ways of using it in order to take full advantage of the power of the latest Java features. Java 11 Cookbook offers a range of software development solutions with simple and straightforward Java 11 code examples to help you build a modern software system.
Starting with the installation of Java, each recipe addresses various problem by explaining the solution and offering insights into how it works. You'll explore the new features added to Java 11 that will make your application modular, secure, and fast. The book contains recipes on functional programming, GUI programming, concurrent programming, and database programming in Java. You'll also be taken through the new features introduced in JDK 18.3 and 18.9.
By the end of this book, you'll be equipped with the skills required to write robust, scalable, and optimal Java code effectively.
What you will learn
- Set up JDK and understand what's new in the JDK 11 installation
- Implement object-oriented designs using classes and interfaces
- Manage operating system processes
- Create a modular application with clear dependencies
- Build graphical user interfaces using JavaFX
- Use the new HTTP Client API
- Explore the new diagnostic features in Java 11
- Discover how to use the new JShell REPL tool
Who this book is for
The book is for intermediate-to-advanced Java programmers who want to make their applications fast, secure, and scalable.
Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
- Installation and a Sneak Peek into Java 11
-
Fast Track to OOP - Classes and Interfaces
- Introduction
- Implementing object-oriented design (OOD)
- Using inner classes
- Using inheritance and aggregation
- Coding to an interface
- Creating interfaces with default and static methods
- Creating interfaces with private methods
- A better way to work with nulls using Optional
- Using the utility class Objects
-
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-Project Jigsaw JDK applications
- Bottom-up migration
- Top-down migration
- Using services to create loose coupling between the consumer and provider modules
- Creating a custom modular runtime image using jlink
- Compiling for older platform versions
- Creating multi-release JARs
- Using Maven to develop a modular application
- Making your library module-path-friendly
- How to open a module for reflection
- Going Functional
-
Streams and Pipelines
- Introduction
- Creating immutable collections using the of() and copyOf() factory methods
- Creating and operating on streams
- Using numeric streams for arithmetic operations
- Completing streams by producing collections
- Completing streams by producing maps
- Completing streams by producing maps using grouping collectors
- Creating stream operation pipeline
- Processing streams in parallel
-
Database Programming
- Introduction
- Connecting to a database using JDBC
- Setting up the tables required for DB interactions
- Performing CRUD operations using JDBC
- Using the Hikari Connection Pool (HikariCP)
- Using prepared statements
- Using transactions
- Working with large objects
- Executing stored procedures
- Using batch operations for a large set of data
- Using MyBatis for CRUD operations
- Using the Java Persistence API and Hibernate
-
Concurrent and Multithreaded Programming
- Introduction
- Using the basic element of concurrency – thread
- Different synchronization approaches
- Immutability as a means of achieving 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
-
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
-
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
- Monitoring the Spring Boot 2 application using Micrometer and Prometheus
- Networking
-
Memory Management and Debugging
- Introduction
- Understanding the G1 garbage collector
- Unified logging for JVM
- Using the jcmd command for the JVM
- Try-with-resources for better resource handling
- Stack walking for improved debugging
- Using the memory-aware coding style
- Best practices for better memory usage
- Understanding Epsilon, a low-overhead garbage collector
- The Read-Evaluate-Print Loop (REPL) Using JShell
-
Working with New Date and Time APIs
- Introduction
- How to work with time zone-independent date and time instances
- How to construct time zone-dependent time instances
- How to create a date-based period between date instances
- How to create a time-based period between time instances
- How to represent epoch time
- How to manipulate date and time instances
- How to compare date and time
- How to work with different calendar systems
- How to format dates using the DateTimeFormatter
- Testing
- The New Way of Coding with Java 10 and Java 11
- GUI Programming Using JavaFX
- Other Books You May Enjoy
Product information
- Title: Java 11 Cookbook
- Author(s):
- Release date: September 2018
- Publisher(s): Packt Publishing
- ISBN: 9781789132359
You might also like
book
Java Hibernate Cookbook
Over 50 recipes to help you build dynamic and powerful real-time Java Hibernate applications About This …
book
Java 17 Recipes: A Problem-Solution Approach
Quickly find solutions to dozens of common programming problems encountered while building Java applications, with recipes …
book
Mastering Java 11 - Second Edition
Update your Java knowledge with the latest features of Java 11, such as the low-Overhead Garbage …
book
Spring Boot 2.0 Cookbook - Second Edition
Take your application development skills to the next level by implementing Spring Boot features effectively About …