Search code examples
javagradlejava-modulejava-platform-module-systemmodule-info

error while exporting module in module-info.java -> Package is empty: projects


Before continuing, take a look on the image below: enter image description here

Any thoughts on why I'm unable to export the same module as my declared module in the module-info.java?

P.S: The highlighted error message has nothing to do with this topic. But if you have any hint on this error, try answering this stackoverflow topic

Thx in advance!


Solution

  • Slight correction, you can use the exports directive for packages and not modules. The declaration syntax is detailed in JLS7.7 as

    exports PackageName [to ModuleName {, ModuleName}] ;
    

    Other few lines of your code(consisting of exports ...) comply with the behavior and seems to be compiling. The reason for the failure on the mentioned line is because the package projects is empty and empty packages are not allowed to be exported by the java module system.