Thursday, 7 January 2021

Module Descriptor: module-info.java

Module is defined by module descriptor file. Module descriptor file contains module name, all the dependent modules and exported packages of this module etc.,

 

Module definition is defined in ‘module-info.java’.

 

module-info.java

module com.helloworld{
   requires java.base;

   exports com.sample.app.util;
}

 

In the above example.

a.   Module name is ‘com.helloworld’. Since modules live in Global namespace, module name must by unique.

b.   ‘requires’ keyword indicates that this module depends on java.base module (Syntax: requires MODULE_NAME).

c.    ‘exports’ keyword indicates that this module exposes ‘com.sample.app.util’ package to outside (exports PACKAGE_NAME).

 

 

 

 

 

Previous                                                    Next                                                    Home

No comments:

Post a Comment