Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to find modules from module-info.java

Tags:

java

java-9

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 requiresline:

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
like image 248
MrSir Avatar asked Aug 04 '17 13:08

MrSir


1 Answers

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.

like image 77
Michael Easter Avatar answered Sep 30 '22 14:09

Michael Easter