Social Media

Java 9 Modules

Java already has some components that hint towards modularity – but doesnt offer true modularity. JSR-376 formally introduces modules into Java.

How we do it currently

Basically we use two approaches –

> Packages – this allows us to group functionality into similar groups
> Jar files – We place all the packages associated with a given component into a jar file

The problem is once we have this structure we’re basically sticking the jar into the classpath and hope for the best.

OK its not that bad – we prop up this mechanism with build tools like maven, and frameworks like Spring and OSGI – but the potential for disaster is still there

Modules address the shortcomings by ensuring the modules –

> Encapsulate implementation details and expose whats needed
> Explicitly describe what they offer & dependencies – verified and resolved automatically during development

A Module graph can be constructed from this

Ive not seen many examples of Java9 modules yet – but will update this post when I have some examples.


About the Author Martin Farrell

My name is Martin Farrell. I have almost 20 years Java experience. I specialize inthe Spring Framework and JEE. I’ve consulted to a range of businesses, and have provide Java and Spring mentoring and training. You can learn more at About or on my consultancy website Glendevon Software

follow me on:

Leave a Comment: