
- Java Tutorial
- Java - Home
- Java - Overview
- Java - Environment Setup
- Java - Basic Syntax
- Java - Object & Classes
- Java - Constructors
- Java - Basic Datatypes
- Java - Variable Types
- Java - Modifier Types
- Java - Basic Operators
- Java - Loop Control
- Java - Decision Making
- Java - Numbers
- Java - Characters
- Java - Strings
- Java - Arrays
- Java - Date & Time
- Java - Regular Expressions
- Java - Methods
- Java - Files and I/O
- Java - Exceptions
- Java - Inner classes
- Java Object Oriented
- Java - Inheritance
- Java - Overriding
- Java - Polymorphism
- Java - Abstraction
- Java - Encapsulation
- Java - Interfaces
- Java - Packages
- Java Advanced
- Java - Data Structures
- Java - Collections
- Java - Generics
- Java - Serialization
- Java - Networking
- Java - Sending Email
- Java - Multithreading
- Java - Applet Basics
- Java - Documentation
- Java Useful Resources
- Java - Questions and Answers
- Java - Quick Guide
- Java - Useful Resources
- Java - Discussion
- Java - Examples
What are the different compilation modes of a module in Java 9?
A module is a container of packages and each module contains a module descriptor that includes module name, module dependencies, it means that the name of other modules depends on and name of the packages it exports that can be used only by modules that depend on it.
module com.tutorialspoint.app { /** Modules upon which the module com.tutorialspoint.app depends on */ requires com.tutorialspoint.services; /** Packages exposed by this module which can be used by other modules */ exports com.tutorialspoint.app.util; }
There are three different compilation modes provided by Java 9 Module: Legacy mode, single module mode, and multi-module mode.
Compilation modes of a Module:
- Legacy Mode: It can be enabled when the compilation environment defined by the --source, --target, and --release options is less than or equal to 8. The compiler behaves the same way as it does in Java 8 (or before) where we can use traditional options (classpath, etc.) rather than any of the modules related options (--module-path). In this mode, our code runs as the unnamed module during runtime.
- Single Module Mode: It can be enabled when the compilation environment is 9 or later and the --module-source-path option is not used. In this mode, the code has structured in a traditional package hierarchical directory tree. The code has a module-info.java file and runs on modulepath rather than on classpath. In this structure, we can place our module-info.java file directly under the src directory. We can't have multiple module-info.java files in the same directory tree, so it's called a single module mode.
- Multi-Module Mode: It can be enabled when the compilation environment is 9 or later and the --module-source-path option is used. In this mode, we place multiple modules under the same source directory. During the compile-time, the main source directory can be specified with the --module-source-path option. The source tree for each individual module can be placed in its own subdirectory under the main source directory.
- Related Articles
- What are the different module types in Java 9?
- What are the different feedback modes in JShell in Java 9?
- What are the characteristics of a module in Java 9?
- What are the benefits of a module in Java 9?
- What are the different modes of nutrition?
- What are the components in a module-info file in Java 9?
- What are the advantages and disadvantages of the Module System in Java 9?
- Importance of Module Descriptor in a Module in Java 9?
- What is Module System in Java 9?
- What are the different status states of REPL in Java 9?
- What are the different modes of operation in Block Cipher in information security?
- What are the Selection Modes in a JTable with Java?
- What is an unnamed module in Java 9?
- What are the different shortcut keys in JShell in Java 9?
- What are the different "/edit" commands in JShell in Java 9?

Advertisements