Moduleis a combination ofcodeanddata, it has a name and is declared to other modules A dependency module that exports a package containing public types accessible outside the module and specifies the services it uses or the service implementations it provides. All of this is specified in themodule-info.javafile, which is included in the module's root directory.
There are two types of "export" clauses that can be used in the "module-info.java" file.
1)Export
We need to allow other modules to use the classes and interfaces of the packagetp.com.tutorialspoint.model, we can write like this:
module com.tutorialspoint.model { exports tp.com.tutorialspoint.model; }
Understand that a package can only appear in This is very important in a module. Otherwise, we will get an error like this:
Error:(1, 1) java: package exists in another module:
2)Export
module com.tutorialspoint.model { exports tp.com.tutorialspoint.model to com.tutorialspoint.gui; }
The above is the detailed content of What is the purpose of "export" clause in module-info file in Java 9?. For more information, please follow other related articles on the PHP Chinese website!