I have 2 different projects in the same folder: com.jdojo.address
and com.jdojo.person
. The first has a simple pojo class Address
and a module-info.java
under default package:
module com.jdojo.address {
exports com.jdojo.address;
}
No errors here.
In the com.jdojo.person
project I have a Person
class that uses an Address
attribute from the previous one. The module-info.java
:
module com.jdojo.person {
requires com.jdojo.address;
exports com.jdojo.person;
}
I have an error in the requires
line:
module not found: com.jdojo.address
I have this issue both with NetBeans IDE Dev (Build 201708030001) and IntelliJ IDEA 2017.2.1.
├───com.jdojo.address
│ ├───.idea
│ │ └───inspectionProfiles
│ ├───nbproject
│ │ └───private
│ └───src
│ └───com
│ └───jdojo
│ └───address
├───com.jdojo.intro
│ ├───.idea
│ │ ├───inspectionProfiles
│ │ └───libraries
│ ├───build
│ │ ├───classes
│ │ │ └───com
│ │ │ └───jdojo
│ │ │ ├───address
│ │ │ ├───intro
│ │ │ └───person
│ │ ├───empty
│ │ └───generated-sources
│ │ └───ap-source-output
│ ├───dist
│ ├───nbproject
│ │ └───private
│ ├───src
│ │ └───com
│ │ └───jdojo
│ │ └───intro
│ └───test
├───com.jdojo.person
│ ├───.idea
│ │ └───inspectionProfiles
│ ├───nbproject
│ │ └───private
│ ├───src
│ │ └───com
│ │ └───jdojo
│ │ └───person
│ └───test
├───lib
├───mods
│ └───com.jdojo.intro
│ └───com
│ └───jdojo
│ └───intro
└───src
└───com.jdojo.intro
└───com
└───jdojo
└───intro
These are the module-info and java classes paths
C:\Java9Revealed\com.jdojo.address\src\module-info.java
C:\Java9Revealed\com.jdojo.address\src\com\jdojo\address\Address.java
C:\Java9Revealed\com.jdojo.person\src\module-info.java
C:\Java9Revealed\com.jdojo.person\src\com\jdojo\person\Person.java
Per the Quick Start guide, it is convention to put the source-code in a folder named after the module. In this case, the folder structure should be:
com.jdojo.address/src/com.jdojo.address/module-info.java
com.jdojo.address/src/com.jdojo.address/com/jdojo/address/Address.java
com.jdojo.person/src/com.jdojo.person/module-info.java
com.jdojo.person/src/com.jdojo.person/com/jdojo/person/Person.java
It is illuminating to experiment using command-line tools, independent of any IDE. I have illustrated this case here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With