Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modules not found that are required in module-info.java

All the required modules I've declared in module-info.java are not being found when I run gradle:

/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:10: error: module not found: com.jfoenix
        requires com.jfoenix;
                    ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:11: error: module not found: google.api.client
        requires google.api.client;
                           ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:12: error: module not found: google.api.services.gmail.v1.rev83
        requires google.api.services.gmail.v1.rev83;
                                             ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:13: error: module not found: google.http.client
        requires google.http.client;
                            ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:14: error: module not found: google.http.client.jackson2
        requires google.http.client.jackson2;
                                   ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:15: error: module not found: google.oauth.client
        requires google.oauth.client;
                             ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:16: error: module not found: google.oauth.client.java6
        requires google.oauth.client.java6;
                                    ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:17: error: module not found: google.oauth.client.jetty
        requires google.oauth.client.jetty;
                                    ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:18: error: module not found: java.xml.bind
        requires java.xml.bind;
                         ^
/Users/Joseph/eclipse-workspace/CheckMyDigitalFootprint/src/main/java/module-info.java:23: error: module not found: org.json
        requires org.json;

module-info.java:

module footprint {

    requires com.jfoenix;
    requires google.api.client;
    requires google.api.services.gmail.v1.rev83;
    requires google.http.client;
    requires google.http.client.jackson2;
    requires google.oauth.client;
    requires google.oauth.client.java6;
    requires google.oauth.client.jetty;
    requires java.xml.bind;
    requires transitive javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires transitive javafx.graphics;
    requires org.json;
    requires java.prefs;

    opens checkmydigitalfootprint to javafx.fxml;


    exports checkmydigitalfootprint.util;
    exports checkmydigitalfootprint;
    exports checkmydigitalfootprint.model;
    exports checkmydigitalfootprint.view;
}

Folder structure:

enter image description here

like image 710
doctopus Avatar asked Dec 10 '18 04:12

doctopus


People also ask

Is module-info java required?

In order to declare a module, we need to include the "module-info. java" file to root source code. 1) requires <module>: By default, a module doesn't know other modules present in a module-path. So, it is necessary to add a line in our module-info.

Where is Java module-info?

The module declaration ( module-info. java ) needs to go into your source root directory (e.g. src/main/java ). It then has to be among the list of files to compile, so it will get turned into a module descriptor ( module-info. class ).

What is module-info in java?

module-info. java file. It declares the dependencies within the module system and allows the compiler and the runtime to police the boundaries/access violations between the modules in your application.


2 Answers

You probably need to ensure to modify the compileJava task as :

compileJava {
    inputs.property("moduleName", moduleName)
    doFirst {
        options.compilerArgs = [
            '--module-path', classpath.asPath,
        ]
        classpath = files()  
    }
}
like image 162
Naman Avatar answered Oct 03 '22 19:10

Naman


In recent Gradle versions (since 6.4 says the Internet; I tested on 6.5), this can be stated more concisely:

java {
    modularity.inferModulePath = true
}

Again, see also: https://guides.gradle.org/building-java-9-modules/

like image 24
Tobias B. Avatar answered Oct 03 '22 18:10

Tobias B.