Modular Programming in Java 9

Kick-start your modular programming journey and gear up for the future of Java development

Access cutting-edge content as it's created

Want access to this book right now? Read as we develop it as part of our Early Access program. Click here to find out more about Early Access.

Modular Programming in Java 9

Koushik Kothagal

Kick-start your modular programming journey and gear up for the future of Java development

Access cutting-edge content as it's created

Want access to this book right now? Read as we develop it as part of our Early Access program. Click here to find out more about Early Access.

$10.00
$39.99
RRP $31.99
RRP $39.99
Early Access eBook
Pre-Order Print
Access every Packt eBook & Video for just $100
 
  • 4,000+ eBooks & Videos
  • 40+ New titles a month
  • 1 Free eBook/Video to keep every month
Find Out More
 
Code Files
Preview in Mapt

Book Details

ISBN 139781787126909
Paperback276 pages

Book Description

The Java 9 module system is an important addition to the language that affects the way we design and organize code and libraries in Java. It provides a new way to achieve maintainable code by the encapsulation of native Java types, as well as a way to write better libraries that have clear interfaces.

The module system is a deviation from the package based method of organizing code in earlier versions of Java. Effectively using the module system requires an understanding of how modules work and what the best practices of creating modules are.

This book will give you step-by-step instructions to create new modules as well as migrate code from earlier versions of Java to the Java 9 module system. It will begin by introducing you to modular programming, and you’ll get to write your first module. It will then go on to explain how inter-module dependencies are handled, and then introduces the modular JDK. Next, you will learn about Module resolution, linking, and using jlink. We will end our journey by taking a look at the road ahead. You will learn how to upgrade your code to Java 9, as well as handle issues with libraries. The final chapter will talk about Java 9 and its relation with OSGi, and how they can be used together.

Table of Contents

Chapter 1: Introducing Java 9 Modularity
Modularity in Java
Rethinking Java development with packages
Java - the twenty year old codebase
Java Platform Module System
Project Jigsaw
Summary
Chapter 2: Creating your first Java module
Setting up the JDK
Java 9 modules
The address book application
Handling possible errors
Summary
Chapter 3: Handling inter-module dependencies
Creating the second module
Compiling two modules
Configuring module dependency
Rethinking package structure
Revisiting classpath
Revisiting the class path problems
Summary
Chapter 4: Introducing the modular JDK
The way things were
Enter Project Jigsaw
Platform modularity
Revisiting the two problems
Summary
Chapter 5: Using platform APIs
Adding logging ability
Reading contacts from an XML file
Adding UI with Java FX
Summary
Chapter 6: Module resolution, accessibility and readability
Readability
Accessibility
Tweaking modularity
Applying the concepts to address book viewer
Summary
Chapter 7: Introducing Services
The problem of coupling
Understanding Services
Advanced Services
Services and the module system goals
Summary
Chapter 8: Understanding linking and using jlink
Module resolution process
Revisiting the state of the JDK
Linking using jlink
Building a modular jar file
Summary

What You Will Learn

  • Get introduced to the concept of modules and modular programming
  • Find out about the challenges of code structure pre-Java 9, and understand why modular programming was introduced in the Java spec.
  • Build and configure your own Java 9 modules
  • Work with multiple modules and establish relationships between them
  • Understand and use the principles of encapsulation, readability, and services
  • Use jlink to work with multiple modules like a pro
  • Discover the best practices to help you write awesome modules that are a joy to use and maintain
  • Upgrade your old Java code to the new Java 9 module system

Authors

Table of Contents

Chapter 1: Introducing Java 9 Modularity
Modularity in Java
Rethinking Java development with packages
Java - the twenty year old codebase
Java Platform Module System
Project Jigsaw
Summary
Chapter 2: Creating your first Java module
Setting up the JDK
Java 9 modules
The address book application
Handling possible errors
Summary
Chapter 3: Handling inter-module dependencies
Creating the second module
Compiling two modules
Configuring module dependency
Rethinking package structure
Revisiting classpath
Revisiting the class path problems
Summary
Chapter 4: Introducing the modular JDK
The way things were
Enter Project Jigsaw
Platform modularity
Revisiting the two problems
Summary
Chapter 5: Using platform APIs
Adding logging ability
Reading contacts from an XML file
Adding UI with Java FX
Summary
Chapter 6: Module resolution, accessibility and readability
Readability
Accessibility
Tweaking modularity
Applying the concepts to address book viewer
Summary
Chapter 7: Introducing Services
The problem of coupling
Understanding Services
Advanced Services
Services and the module system goals
Summary
Chapter 8: Understanding linking and using jlink
Module resolution process
Revisiting the state of the JDK
Linking using jlink
Building a modular jar file
Summary

Book Details

ISBN 139781787126909
Paperback276 pages
Read More

Read More Reviews