Study guide
10.3 Modular Compilation, Packaging, and CLI Execution
Oracle Java SE 21 Developer 1Z0-830
Track your progress as you read
Finished sections get a check mark.
1 Chapter 1: Java Basics, Primitive Types, and Operators
1.1 Program Structure, Primitives, Literals, Scopes, and var 1.2 Operators, Precedence, and Type Casting 1.3 Strings, Text Blocks, and StringBuilder 1.4 Date and Time APIs (java.time)
2 Chapter 2: Controlling Program Flow & Pattern Matching
2.1 Conditional Logic: if-else and Ternary Operators 2.2 Switch Statements and Switch Expressions 2.3 Pattern Matching for switch and instanceof 2.4 Loops and Branching Statements
3 Chapter 3: Object-Oriented Design & Class Architecture
3.1 Class Declarations, Constructors, and Object Lifecycle 3.2 Encapsulation and Access Modifiers 3.3 Inheritance, Method Overriding, and Polymorphism 3.4 Abstract Classes and Interfaces 3.5 Nested, Inner, Local, and Anonymous Classes 3.6 Method Overloading, Overload Resolution, and Varargs
4 Chapter 4: Modern Java Data Modeling: Records, Enums, and Sealed Types
4.1 Java Records, Canonical/Compact Constructors, and Component Accessors 4.2 Java Enums: Fields, Methods, and Abstract Constant-Specific Behavior 4.3 Sealed Classes and Interfaces: permits, final, non-sealed, and Hierarchy Architecture 4.4 Advanced Record Patterns (JEP 440), Nested Deconstruction, and Sealed Hierarchy Exhaustiveness
5 Chapter 5: Exception Handling and Annotations
5.1 Exception Hierarchy: Checked vs. Unchecked Exceptions 5.2 Exception Handling: try, catch, finally, and Multi-Catch 5.3 Resource Management: try-with-resources and AutoCloseable 5.4 Custom Exceptions and Best Practices 5.5 Java Annotations: Built-in, Meta-Annotations, and Custom Types
6 Chapter 6: Generics and the Collections Framework
6.1 Generics Fundamentals and Generic Methods 6.2 Wildcards, Type Bounds, and Type Erasure 6.3 Core Collections: Lists, Sets, Queues, and Maps 6.4 Sequenced Collections in Java 21 6.5 Sorting, Comparable, and Comparator 6.6 Arrays: Creation, Multidimensional Forms, and the Arrays Utility Class
7 Chapter 7: Functional Programming & Lambda Expressions
7.1 Built-in Functional Interfaces in java.util.function 7.2 Lambda Expressions, Variable Scopes, and Effectively Final 7.3 Method References: Four Varieties and Edge Cases 7.4 Working with java.util.Optional
8 Chapter 8: The Stream API and Data Pipelines
8.1 Stream Creation and Intermediate Operations 8.2 Terminal Operations and Reductions 8.3 Advanced Collectors, Grouping, Partitioning, and Teeing 8.4 Primitive Streams and Parallel Stream Processing
9 Chapter 9: Concurrency, Multithreading, and Virtual Threads
9.1 Thread Fundamentals, Creation, and Lifecycle 9.2 Thread Safety, Synchronization, and the Java Memory Model 9.3 Concurrency Utilities: ExecutorService, Callable, and Future 9.4 Concurrent Collections, Atomics, and Explicit Locks 9.5 Virtual Threads in Java 21 (Carrier Threads, Pinning, and Best Practices)
10 Chapter 10: The Java Platform Module System (JPMS)
10.1 Module Architecture and module-info.java Declarations 10.2 Module Directives: requires, exports, opens, provides, and uses 10.3 Modular Compilation, Packaging, and CLI Execution 10.4 Module Types, Migration Strategies, ServiceLoader SPI, and JLink
11 Chapter 11: Java I/O, NIO.2, and Object Serialization
11.1 Classic Java I/O Streams and Readers/Writers 11.2 Java NIO.2 File API: Path, Paths, and File System Operations 11.3 Advanced NIO.2 Stream Operations and Directory Traversal 11.4 Java Object Serialization and Record Serialization
12 Chapter 12: Implementing Localization and Internationalization
12.1 Locales and Resource Bundles 12.2 Formatting and Parsing Numbers, Currencies, Dates, Times, and Messages
10.3 Modular Compilation, Packaging, and CLI Execution
Key Takeaways Explain This Topic AI
Modular compilation with javac relies on --module-path (-p) to locate precompiled module dependencies and --module-source-path to compile multiple module source trees in a single atomic invocation.
The java runtime launches modular applications using --module-path (-p) and --module (-m), specified in the standard format <module-name>/<main-class-name> or <module-name> if the main class is embedded in the modular JAR.
The separator between module name and main class in CLI invocations is strictly a forward slash (/), regardless of operating system platform.
The jar tool packages modular binaries, checks descriptor validity, and embeds execution metadata including the main class (--main-class) and version string (--module-version) directly into module-info.class.
The jdeps tool performs static bytecode dependency analysis, detects missing module declarations, and scans for illegal references to deprecated internal JDK APIs with --jdk-internals.
Last updated: September 2026
Modular Compilation, Packaging, and CLI Execution
The Java Platform Module System introduces dedicated command-line options across standard JDK tools including javac (compiler), jar (archiver), java (launcher), and jdeps (dependency analyzer). For the 1Z0-830 exam, mastering exact CLI flag syntax, multi-module source path structures, modular JAR descriptors, runtime execution flags, and static analysis diagnostics is essential.
1. Modular CLI Options Master Matrix
Understanding the standard command-line flags and their short forms across the JDK toolset is heavily tested on the exam.
Option / Flag Short Flag Tool Description
--module-path <path> -p javac , java , jar , jdeps Specifies search path for application modules and modular JARs (replaces -cp / --class-path ).
--module-source-path <path> N/A javac Specifies base directory containing multiple module source subdirectories.
--module <module>[/<mainclass>] -m java , javac Specifies the main module and optional main entry point class to execute or compile.
-d <dir> N/A javac Output destination directory for compiled .class files.
--module-version <ver> N/A jar , javac Embeds a version string (e.g., 2.1.0 ) into module-info.class .
--main-class <class> -e jar Embeds the default application entry-point class into module-info.class .
--describe-module -d jar , java Inspects and prints module descriptor metadata from a modular JAR or runtime module.
--list-modules N/A java Lists all observable platform and application modules.
--show-module-resolution N/A java Traces step-by-step module graph resolution at startup.
--list-deps N/A jdeps Analyzes and lists all modular dependencies for a class or JAR.
--jdk-internals N/A jdeps Scans for deprecated internal JDK APIs (e.g., sun.misc.* ).
2. Compiling Modular Code with javac
Modular compilation with javac can operate in single-module mode or multi-module mode.
Single-Module Compilation
When compiling a single module whose source files are located under src/com.app : # Compiling module descriptor and source files to destination output 'mods/com.app'
- javac -d mods/com.app \
- src/com.app/module-info.java \
- src/com.app/com/app/Main.java \
- src/com.app/com/app/model/Order.java
- Compiling Dependent Modules with --module-path ( -p )
When compiling a module that depends on another pre-compiled module located in the mods directory: javac -p mods \
- d mods/com.client \
- src/com.client/module-info.java \
- src/com.client/com/client/Runner.java
The -p (or --module-path ) flag tells javac where to locate compiled module artifacts ( module-info.class files or modular JARs).
The -d flag specifies the target output directory for compiled class files.
Multi-Module Source Tree Compilation with --module-source-path
When multiple modules are developed in a single source tree, javac can compile all modules atomically in a single command using --module-source-path .
Directory Structure Requirement :
Each module source subdirectory under the source root must exactly match the module name declared in its module-info.java . project/
- └── src/
- ├── com.app.core/
- │ ├── module-info.java
- │ └── com/app/core/CoreService.java
- └── com.app.client/
- ├── module-info.java
└── com/app/client/Main.java # Compiles all modules defined under src into their respective mods/<module-name> subdirectories
javac --module-source-path src -d mods $(find src -name "*.java")
# Or compile specific modules from the source tree:
javac --module-source-path src -d mods --module com.app.core,com.app.client
Note
During multi-module compilation, javac automatically determines the inter-module dependency order and compiles dependent modules in the correct sequence.
3. Packaging Modular JARs with jar
A Modular JAR is an archive that contains a compiled module-info.class in its root directory, alongside standard compiled class files and package directories.
- 1. Basic Modular JAR Creation # Create directory for packaged JARs
- mkdir -p mlib
# Package the compiled module into a modular JAR
jar --create --file mlib/com.app.core.jar -C mods/com.app.core .
2. Embedding Main Class and Module Version
The jar tool allows embedding metadata directly into module-info.class : jar --create --file mlib/com.app.client-1.0.jar \
- -main-class com.app.client.Main \
- -module-version 1.0.0 \
-C mods/com.app.client .
--main-class <fqcn> (or -e ): Specifies the binary entry-point class.
--module-version <version> : Embeds a module version string into the descriptor.
- 3. Updating an Existing Modular JAR jar --update --file mlib/com.app.client-1.0.jar \
- -main-class com.app.client.Main
- 4. Inspecting a Modular JAR with --describe-module
To verify the descriptor content of a packaged modular JAR: jar --describe-module --file mlib/com.app.client-1.0.jar
# Or using short flags:
- jar -d -f mlib/com.app.client-1.0.jar
- Sample Output : com.app.client@1.0.0 jar:file:.../mlib/com.app.client-1.0.jar!/module-info.class
- exports com.app.client.api
- requires com.app.core
- requires java.base mandated
- main-class com.app.client.Main
- 4. Running Modular Applications with java
The java launcher boots the Java Virtual Machine using the module path.
- Execution Syntax Patterns # Pattern 1: Full syntax with explicit module and main class
- java --module-path mlib --module com.app.client/com.app.client.Main
- # Pattern 2: Short flags (-p and -m)
- java -p mlib -m com.app.client/com.app.client.Main
- # Pattern 3: Short syntax when Main-Class is embedded in module-info.class
- java -p mlib -m com.app.client
- # Pattern 4: Passing application command-line arguments
- java -p mlib -m com.app.client/com.app.client.Main arg1 arg2 --verbose
Important
When executing via -m <module>/<mainclass> , the forward slash ( / ) separates the module name from the fully qualified class name . The separator is always a forward slash / , regardless of operating system (Windows, macOS, Linux). Never use colons, semicolons, or dots as the module-to-class separator.
5. Diagnostic and Migration Flags
When running modular applications or troubleshooting migration issues, the java launcher offers specialized flags:
--show-module-resolution : Logs the module resolution process step-by-step during JVM startup, showing root modules, required modules, and resolved bindings.
--list-modules : Prints all modules observable by the runtime (built-in platform modules and modules found on the module path).
--add-modules <module-list> : Explicitly adds root modules to the default root set for module graph resolution (vital when running tests or loading optional modules).
--add-exports <module>/<package>=<target-module> : Patches a module at runtime to export an internal package, breaking encapsulation for legacy migration.
--add-opens <module>/<package>=<target-module> : Patches a module at runtime to open an internal package for deep reflection.
6. Dependency Diagnostics with jdeps
The jdeps tool analyzes static byte-code references in class files and JAR archives to discover required modules and detect illegal API usage. # High-level module dependency summary
jdeps --summary -p mlib mlib/com.app.client-1.0.jar
# Output:
- # com.app.client -> com.app.core
- # com.app.client -> java.base
- # List all required platform and application modules
- jdeps --list-deps mlib/com.app.client-1.0.jar
- # Check module descriptor for unused dependencies or missing requires
- jdeps --check com.app.client -p mlib mlib/com.app.client-1.0.jar
- # Scan legacy code for usage of deprecated internal JDK APIs
- jdeps --jdk-internals legacy-app.jar
- Understanding jdeps --jdk-internals Output
When migrating legacy libraries, jdeps --jdk-internals flags problematic classes and suggests standard replacement APIs: legacy-app.jar -> jdk.unsupported
- com.legacy.crypto.CipherUtil -> sun.misc.BASE64Encoder JDK internal API (JDK removed / encapsulated)
- Suggested replacement: Use java.util.Base64