This chapter covers:
- different directory structures for a project
- compilation of sources from a single module to class files
- compilation of multiple modules at the same time
- packaging class files into a modular JAR
Being able to define modules as described in chapter 3 is a good skill to have, but what is it good for without knowing how to turn those source files into modular artifacts (meaning JARs, short for Java Archives) that can be shipped and executed? This chapter looks into building modules, all the way from organizing sources, to compiling them to class files, and eventually packaging those into modular JARs that can be distributed and executed. Chapter 5 focuses on running and debugging modular applications.
At times we will look at the javac
and jar
commands that are available on the command line. You might be wondering about that—aren’t IDEs and other tools going to use them for you? Likely, yes, but even putting the argument aside that it is always good to know how those tools work their magic, there is a more important reason to get to know these commands: They are the most direct path into the module system’s heart. We will use them to explore its features in and out and when we’re done, you can use any tool that gives access to these features.