Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Modular Programming in Java 9

You're reading from   Modular Programming in Java 9 Build large scale applications using Java modularity and Project Jigsaw

Arrow left icon
Product type Paperback
Published in Aug 2017
Publisher Packt
ISBN-13 9781787126909
Length 298 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Koushik Srinivas Kothagal Koushik Srinivas Kothagal
Author Profile Icon Koushik Srinivas Kothagal
Koushik Srinivas Kothagal
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Introducing Java 9 Modularity 2. Creating Your First Java Module FREE CHAPTER 3. Handling Inter-Module Dependencies 4. Introducing the Modular JDK 5. Using Platform APIs 6. Module Resolution, Readability, and Accessibility 7. Introducing Services 8. Understanding Linking and Using jlink 9. Module Design Patterns and Strategies 10. Preparing Your Code for Java 9 11. Migrating Your Code to Java 9 12. Using Build Tools and Testing Java Modules

What this book covers

Chapter 1, Introducing Java 9 Modularity, covers the status quo of code structuring and management in Java 8 and before. It outlines the challenges and pitfalls in maintaining and organizing large code bases over time, with the example of a large Java code base everyone is familiar with--the JDK. It then introduces Project Jigsaw and explains how the concept of modularity attempts to solve the challenges outlined in the previous chapter. It discusses the module-based changes to the JDK structure as well as the ability to create modules in application code.

Chapter 2, Creating Your First Java Module, gets you started on a sample code project that is written without using the module construct. It then guides you step-by-step through creating your first Java 9 module. It introduces you to the module keyword, the module-info.java class and how to define a custom Java module. It then covers compiling and running a module. It explains the structure of the .class files and how the runtime uses the same module definition to infer the module structure.

Chapter 3, Handling Inter-Module Dependencies, shows how modules can hardly work well in isolation. They are designed to be parts of a bigger unit and are meant to work with each other. This chapter covers creating a second module and having the modules depend on each other. You'll learn how to define such a relationship in Java 9, as well as how to compile and run a multi-module application.

Chapter 4, Introducing the Modular JDK, switches our attention to the Java platform, specifically the JDK. You'll learn about the important changes to the JDK that has resulted from the modularization of the platform. You'll learn about the modules that come out of the box with the JDK. You'll also learn about the tools and techniques to browse and get more information about any of those modules.

Chapter 5, Using Platform APIs, teaches you how to use the platform modules in the sample application through a hands-on step-by-step guide. You'll understand some of the challenges that you may typically face when depending on platform modules and how to solve them.

Chapter 6, Module Resolution, Readability, and Accessibility, delves deep into inter-module dependencies and how you can control the level of encapsulation for their modules and libraries. It continues the module resolution discussion of the previous chapter by adding two new criteria that influences the encapsulation and availability of Java elements--accessibility and readability.

Chapter 7, Introducing Services, looks at a vital element of coupling that exists between two modules in the sample application and how that prevents the extensibility and "plugging-in" of new modules. It explains the new Java 9 services, provides step-by-step instructions to encapsulate implementation classes, and uses ServiceLoader to look them up.

Chapter 8, Understanding Linking and Using jlink, introduces the static linking step in the Java 9 development process and what happens during it. It explains how linking plays an important part when developing modules in Java 9. It then provides step-by-step instructions to create a runtime image for the sample project, how to optimize it, and how to execute the image.

Chapter 9, Module Design Patterns and Strategies, covers several best practices when it comes to building modular applications in Java. Now that you have a good understanding of the Java module system features and how it works, the next question is when and how to use them? You'll learn how to establish module scopes and boundaries, how to define good module interfaces, and how to tackle some common challenges when building a modular application.

Chapter 10, Preparing Your Code for Java 9, walks you through getting an old sample code base (written in Java 7) ready to be migrated to Java 9. It illustrates the optional nature of Java modules and how a classpath-based code is automatically assigned to an "unnamed" module. It then provides step-by-step instructions to get legacy code to compile and run in Java 9. It also shows you how to handle issues with usage of encapsulated types, and how to work around them.

Chapter 11, Migrating Your Code to Java 9, walks you through upgrading legacy code to use the new modularity features of Java 9. You'll learn how to form a migration strategy for your code, as well as how to deal with dependencies that are not compatible with Java 9. You'll learn how to use Java 9 features that are designed to assist such migration, such as automatic modules and command-line overrides.

Chapter 12, Using Build Tools and Testing Java Modules, covers two important aspects of Java programming--build tool integration and unit testing. You'll learn to use Maven to structure your projects and align Maven's multi-module project concepts with Java 9 modular applications. You'll also learn how to test Java modules using JUnit.

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