Kappa123
Kappa123

Reputation: 351

"Module not found" message when generating JavaDocs in Eclipse

I'm trying to generate JavaDocs in my application, however, when I try it, I get the following message:

...\application\src\module-info.java:5: error: module not found: javafx.base
    requires javafx.base;
                   ^
...\application\src\module-info.java:6: error: module not found: javafx.fxml
    requires javafx.fxml;
                   ^
...\application\src\module-info.java:7: error: module not found: javafx.graphics
    requires transitive javafx.graphics;
                              ^
...\application\src\module-info.java:8: error: module not found: javafx.media
    requires javafx.media;
                   ^
...\application\src\module-info.java:9: error: module not found: javafx.controls
    requires javafx.controls;
                   ^
...\application\src\module-info.java:10: error: module not found: org.junit.jupiter.api
    requires org.junit.jupiter.api;

And i'm not exactly sure what it means. I've tried googling it but didn't really find anything useful, found a very similiar question but it was never answered. What could be the issue?

My classes filepath is as follows: ...\application\src\game\game.main

My modulepath filepath is as follows:...\application\src\module-info.java

My application runs fine so i'm not really sure what the issue could be.

This is how my module-path.java looks like:

module froggerGame 
{
    exports frogger.helper;
    exports frogger.builders;
    exports tests;
    exports frogger.controllers;
    exports frogger.world;
    exports frogger.actors;
    exports frogger.game;
    requires javafx.base;
    requires javafx.controls;
    requires javafx.fxml;
    requires javafx.graphics;
    requires javafx.media;
    requires org.junit.jupiter.api;
}

EDIT: I managed to fix the issue, the problem was that I didn't set up my Java Executable Variables correctly (JAVA_HOME , PATH_TO_FX) and then in the arguments of the VM for JavaDocs, I had to include the --add-module bit as well as the location of my lib folder in JavaFX

Thanks.

Upvotes: 8

Views: 4756

Answers (2)

Andrew S
Andrew S

Reputation: 2987

The problem seems to be a long standing problem in Eclipse that's been there since Java 9 was supported and JavaFX became an independent module external to the Java SDK.

The problem is that Eclipse does not automatically pass information related to the JavaFX module to the JavaDoc call. I guess if it had to do that for each module their users might commonly employ, this would be an impossible task for Eclipse's developers.

Thankfully we can do it by ourselves. Using the third screen of the JavaDoc wizard (clicking next twice) allows us to specify VM options. Add the following and change the path to where your JavaFX is installed.

--module-path "C:\Java\javafx-sdk-13.0.1\lib"

You should find after this your JavaDocs generate without the aforementioned error being raised. I just tried this in my 2021-06 version and it works, I have used this solution in prior versions too.

Upvotes: 1

Andrew S
Andrew S

Reputation: 2987

I have found temporarily deleting thee module-info.java file, generating the JavaDocs then hitting undo to bring the module-info.java back works.

This is a quick fix, but Eclipse really needs a little button on the JavaDoc wizard to disable linting.

Upvotes: 1

Related Questions