Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"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.

like image 292
Kappa123 Avatar asked Dec 15 '19 16:12

Kappa123


People also ask

What is module-info java in Eclipse?

Yes, module-info. java was introduced in Java 9, with the Project Jigsaw module system. A module is a build artifact (usually a Jar file) that contains a module descriptor that declares the name of the module, what other modules it depends on, what packages it exposes to other modules, and what services it implements.

What is the javadoc Command in eclipse?

The javadoc command parses the declarations and documentation comments in a set of Java source files and produces a corresponding set of HTML pages that describe (by default) the public and protected classes, nested classes (but not anonymous inner classes), interfaces, constructors, methods, and fields.

What is module-info 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.


1 Answers

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.

like image 120
Andrew S Avatar answered Sep 30 '22 16:09

Andrew S