4 Building modules from source to JAR
This chapter covers
- Project directory structures
- Compiling sources from a single module to class files
- Compiling 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 (JARs) 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’ll look at the javac and jar commands available on the command line. You may be wondering about that—aren’t IDEs and other tools going to use them for you? Likely, yes, but even putting aside the argument that it’s always good to know how those tools work their magic, there is a more important reason to get to know these commands: they’re the most direct path into the module system’s heart. We’ll use them to explore its features inside and out, and when we’re done, you can use any tool that gives access to these features.