The Java module system offers new ways of creating modular and maintainable applications. With this hands-on book, Java developers will learn not only about the joys of modularity, but also about the patterns needed to create truly modular and reliable applications.
Authors Sander Mak and Paul Bakker teach you the concepts behind the Java module system, along with the new tools it offers. You’ll also learn how to modularize existing code and how to steer clear of common pitfalls when migrating to Java 9.
BuyStarting with the modular JDK, you'll see modules are all about strong encapsulation and explicit dependencies. Then it's time to write your own modules, with services to decouple modules.
After the mechanics of creating modules, the first part closes with modularity patterns. They are essential to create truly modular applications.
We all have existing code. Even though the module system is opt-in, there are many changes affecting classpath-based applications as well.
In the second part we explain how you can migrate to Java 9, and then modularize your application. It also features a case study migrating a Spring and Hibernate application to modules.
The last part focuses on tools and processes for modular development, such as Maven. Also, testing modules brings new challenges.
Another exciting tool is jlink. With jlink, you can create small custom runtime images, bundling only the required application modules and JDK modules in a single low-footprint distribution.
Follow @javamodularity All code examples are available on GitHub so you can easily try them yourself. Star
The art of structuring large codebases is an undervalued one. This is neither a new problem, nor is it specific to Java. However, Java is one of the mainstream languages in which very large applications are built all the time—often making heavy use of many libraries from the Java ecosystem. Under these circumstances, systems can outgrow our capacity for understanding and efficient development. A lack of structure is dearly paid for in the long run, experience shows.
Modularity is one of the techniques you can employ to manage and reduce this complexity. Java 9 introduces a new module system that makes modularization easier and more accessible. It builds on top of abstractions Java already has for modular development. In a sense, it promotes existing best practices on large-scale Java development to be part of the Java language.
The Java module system will have a profound impact on Java development. It represents a fundamental shift to modularity as a first-class citizen for the whole Java platform. Modularization is addressed from the ground up, with changes to the language, Java Virtual Machine (JVM), and standard libraries.
Now is the time to read up on modules. JDK 9 itself is modularized (shown right) so you will encounter modules right from the start. See how they can improve the structure and integrity of your applications.
— Introduction of Java 9 Modularity
(Excerpt from Chapter 1)
Modularization is hard. Luckily I've been able to use Paul and Sander's book as my guide for writing my Java 9 tutorials, talks, and converting jClarity's applications to use Java's new modular system. I'm buying a copy for all the engineering team at jClarity, it's that good!
CEO, jClarity and Java Champion
This book delivers the essential practical knowledge you need to create modular applications in Java 9. It's a must read for any developer or architect wanting to adopt one of the most significant features the JDK has seen in many years.
Director of Developer Relations, ZeroTurnaround
Sander and Paul are expert practitioners of Java and trusted guides to the Java 9 ecosystem. They were on the front lines of Java 9’s development, and in the vanguard of efforts to migrate popular open source libraries. “Java 9 Modularity” is the handbook for everyone interested in the core principles and best practices of modularity in Java: application developers looking to create maintainable components; library developers looking for advice on migration and reflection; and framework developers wishing to exploit the module system’s advanced features. This book will help you to create Java programs whose structure lets them stand the test of time.
Java Platform Group, Oracle
O'Reilly Safari offers the largest selection of IT books on a subscription basis. You can read Java 9 Modularity with a Safari subscription.
No subscription? Start a trial!
Available in all popular formats. Note that only the ebooks.com PDF has the original O'Reilly print typesetting.
This two hour video course gives you insight into the Java module system using practical examples. You'll learn how to create and use modules and how to migrate your applications to Java 9.
Watch (free trial available)This 3,5 hour video course shows all important new features of Java 9 in a hands-on manner. Topics range from JShell to Stream/Optional API enhancements, new APIs like HttpClient and ProcessHandle, performance and security improvements in Java 9 and much more.
Watch (free trial available)Handling dependency injection using Java modularity (O'Reilly article)
9 New Features in Java 9 (blog)
Java 9 Modularity in Action (Devoxx Belgium talk)
Designing for Modularity with Java 9 Modules (JavaOne talk)