O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

The first step in modularizing your application is to understand its dependency graph. Let's create a dependency graph for our application. And for that, we make use of jdeps tool. If you are wondering what jdeps tool is, stop right away and read the recipe: Using jdeps to find dependencies in a Java application. OK so let's run the jdeps tool:

jdeps -summary -R -cp calculator/lib/*:math_util/out/*:banking_util/out/* calculator/out/calculator.jar

We are asking jdeps to give us a summary of the dependencies of our calculator.jar and then do this recursively for each dependency of calculator.jar. And the output we get is:

banking.util.jar -> java.base calculator.jar -> banking_util/out/banking.util.jar calculator.jar -> calculator/lib/jackson-databind-2.8.4.jar ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required