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.
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.
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.
Related
My NetBeans cannot find any main file in the project. This problem occurs only if the main file is inside some package. But due to project specifics, the main file cannot be on the top of the package tree.
I tried all advices which I found (clear cash, copy all files into a new project, create another main file...). Nothing works.
I am afraid that the problem can be caused by the modular system of java. I am using a traditional ANT build with NetBeans configuration.
EDIT: I find out that if I remove module-info file, the problem disappears (but it must be in the project -> required by the project leader).
module MiningFlow {
requires GraphVizualization;
requires dockfx;
requires javafx.swt;
requires javafx.base;
requires javafx.controls;
requires javafx.fxml;
requires javafx.graphics;
requires javafx.media;
requires javafx.swing;
requires javafx.web;
requires MiningGIT;
opens workflow;
opens appstart to javafx.graphics;
opens impl.parameters.selectattrs to javafx.fxml;
}
If I click on the file and if I start it manually from the project, everything works.
MY SETUP:
I followed the steps for the JavaFX and IntelliJ -> Modular from IDE path.
I added the ikonli-core-12.2.0.jar, ikonli-javafx-12.2.0.jar and ikonli-carbonicons-pack-12.2.0.jar via the repository to the Scene Builder in this order. Here, they work fine.
Then I added those same .jars in that same order to the IntelliJ as described here: Correct way to add external jars (lib/*.jar) to an IntelliJ IDEA project.
My module-info.java file contains the following code:
module project {
requires javafx.controls;
requires javafx.fxml;
requires org.kordamp.ikonli.core;
requires org.kordamp.ikonli.javafx;
requires org.kordamp.ikonli.carbonicons;
opens com.project to javafx.fxml;
exports com.project;
}
Picture of my libraries:
PROBLEM:
When I add an icon to the .fxml file and I click on Run, I get the following error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.kordamp.ikonli.javafx not found, required by project
The module name varies. Sometimes it says it's the javafx, others the core or the carbonicons.
I'm not sure why this happens. When I'm typing in the module-info.java file I get the autofill prompts, , but when I try, for example, import org.kordamp.ikonli.core; in my Main.java, it doesn't detect them.
I'm not sure why this happens. When I'm typing in the module-info.java file or try import org.kordamp.ikonli.javafx.FontIcon; in my Main.java, I get the autofill prompts, so it means it's detecting them.
If I remove the "ikonli requires" from the module-info.java and run it, I get this error (which is kind of understandable):
java.lang.ClassNotFoundException: org.kordamp.ikonli.javafx.FontIcon
SOLUTIONS I'VE TRIED:
Adding the .jars via File -> Project Settings -> Libraries.
This seems to automatically add them to the Modules -> Dependencies, but even so, the problem persists.
Adding them in the VM Options (Run -> Edit Configuration -> Modify Options -> VM Options) in various ways, right after the --module-path ${PATH_TO_FX}:out/production mentioned in the steps linked above (out can be safely changed to mods but I chose not to do that).
First:
--module-path ${PATH_TO_IKONLI_CORE}, --module-path ${PATH_TO_IKONLI_JAVAFX} and --module-path ${PATH_TO_IKONLI_CARBONICONS}
Doing this makes it so my actual project module doesn't get detected. I.E. I get this error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module project not found
Second:
--add-modules ${PATH_TO_IKONLI_CORE},${PATH_TO_IKONLI_JAVAFX},${PATH_TO_IKONLI_CARBONICONS}
This one produces a smiliar error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module /directory/path/to/file/ikonli-core-12.2.0.jar not found
Third:
--add-modules org.kordamp.ikonli.core,org.kordamp.ikonli.javafx,org.kordamp.ikonli.carbonicons
A similar error shows up:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module org.kordamp.ikonli.core not found
I tried File -> Reload all from disk and Invalidate Caches / Restart options, but they seem to have had no effect.
I created a lib folder in my src project folder, put the .jars there and added them as dependencies. Now they didn't show up in the External Libraries section (because they're not external obviously) but the problem remains (I'll re-add them as external again).
ADDITIONAL INFORMATION:
I've added controlsfx.jar the same way as the Ikonli .jars. The same error occurs for it as well.
They all have their module-info.class file in the proper directory as stated in the official javadoc, yet the ModuleFinder still throws the exception.
I've also checked my project.iml file and they all have the module-libraries with the correct directories present.
I've revisted the official Ikonli installation steps multiple times and everything checks out.
Though, in there it mentions that I need to have requires javafx.base; requires javafx.graphics; in the module descriptor. Not true, at least in my case, because when I add --show-module-resolution to the VM Options, it shows that they're loaded fine, but even when I do add them, the error still appears.
END
Sorry for the long post, I'm out of ideas and I don't know what else to try.
One of the comments here mentioned that they'd put their .jar in the mods/production folder. I did the same... and it worked. (╯°□°)╯︵ ┻━┻
I guess "Modular from IDE" doesn't agree with the IDE.
Looks like the proper way to go about modular is to use Maven/Gradle. I'll rebuild and go with Gradle.
Platform - Windows
JAVA-11
module-info.java:
module UdemyJavaFX {
requires javafx.controls;
requires javafx.fxml;
requires java.desktop;
opens sample;
}
It shows error:
Error:(1, 1) java: module UdemyJavaFX reads package java.awt from both java.desktop and java.datatransfer
When I created a new project it works fine no error than I figured out error was in Intellij files on further exploring I figured out error was in workspace.xml.
As soon as I copied workspace.xml from new project to this one it works fine.
I was not able to figure out What could be the cause of error and exactly which lines are responsible for it?
I created a Java 13 project that uses the modular system, and want to use LITIEngine, a game library made with java 8.
After adding the dependency in Maven using :
<dependency>
<groupId>de.gurkenlabs</groupId>
<artifactId>litiengine</artifactId>
<version>0.4.18</version>
</dependency>
I was expecting to use it as an automatic module, in my module-info.java:
module com.myproject {
require litiengine; // Error: Module litiengine not found.
}
Surprisingly enough, it doesn't seem to be an automatic module, so I grabbed the jar and ran the command jar --file=litiengine-0.4.18.jar --describe-module, and got this weird result:
java.xml.bind jar:file:///D:/WhereverMyJarIs/litiengine-0.4.18.jar/!module-info.class
exports javax.xml.bind
exports javax.xml.bind.annotation
exports javax.xml.bind.annotation.adapters
exports javax.xml.bind.attachment
exports javax.xml.bind.helpers
exports javax.xml.bind.util
requires java.activation transitive
requires java.base mandated
requires java.desktop
requires java.logging
requires java.xml transitive
uses javax.xml.bind.JAXBContextFactory
So, I am supposed to use LITIEngine as java.xml.bind? It doesn't have anything to do with the library I want to use. This makes no sense!
I still tried to require it:
module com.myproject {
requires java.xml.bind; // IntelliJ gives an error: Ambiguous module reference: java.xml.bind
}
Despite the error IntelliJ gives me, i tried to compile my project with Maven, containing a simple HelloWorld.java file:
package com.myproject;
import de.gurkenlabs.litiengine.Game;
public class HelloWorld {
public static void main(String[] args) {
Game.init(args);
Game.start();
}
}
When running mvn compile, the compilation fails (I set maven.compiler.target and maven.compiler.source to 13):
Error:(3,21) java: package de.gurkenlabs.litiengine is not visible
At this point, I just tried to use my project as a nonmodular one, but still use Java 13, so i just deleted the module-info.java, and like that, it works. Great, but I lose the ability to use the module system, which i need to use in my project.
I tried one last thing, I used the LITIEngine jar i grabbed earlier, and removed the module-info.class file in it, by opening the jar file as an archive in 7-zip and deleting that file. Then I added it as a local dependency in maven with:
mvn install:install-file -Dfile=./whereverItIs/litiengine-0.4.18.jar \
-DgroupId=com.myproject.jars -DartifactId=litiengine -Dversion=1 -Dpackaging=jar
And I added it as a dependency:
<dependency>
<groupId>com.myproject.jars</groupId>
<artifactId>litiengine</artifactId>
<version>1</version>
</dependency>
I could then use the library in my module-info.java
module com.myproject {
require litiengine; // No errors this time!
}
And then successfully build it and run it!
So, this proves that this library can work with when imported as an automatic module, but this requires me to edit the jar file and remove the module-info.class in order to make it work, which is very undesirable, because this requires manual action everytime the library receives an update.
The perfect solution would be to be able to ignore the module-info.class file contained inside the jar and make the module system threat it as an automatic module, is there a way to do that?
I would like to use ResponseSubscribers.ByteArraySubscriber that is in jdk.internal.net.http. I use openjdk11.
I tried 2 things :
1/
I added to maven compiler plugin exports module
<compilerArgs>
<arg>--add-exports</arg><arg>java.net.http/jdk.internal.net.http=fr.app</arg>
</compilerArgs>
-> it compile !
2/
I created module-info.java
module fr.app {
requires java.net.http;
requires com.fasterxml.jackson.core;
requires com.fasterxml.jackson.databind;
requires com.fasterxml.jackson.datatype.jsr310;
exports fr.app;
exports fr.app.parser;
}
There is an error when running a junit test that use the class importing jdk.internal.net.http
fr.app.AppException: java.io.IOException: class fr.app.MyClass$BodySubscribers (in unnamed module #0x6537cf78) cannot access class jdk.internal.net.http.ResponseSubscribers$ByteArraySubscriber (in module java.net.http) because module java.net.http does not export jdk.internal.net.http to unnamed module #0x6537cf78
I understand BodySubscribers must be exported only in named module. But my module is name fr.app right ?
But my module is name fr.app right ?
Not really, while you've created the module-info.java in your project, during the execution of your application your actual code seems to be found on the classpath eventually.
Hence your MyClass is residing in the unnamed module and the error reads as follows
class fr.app.MyClass$BodySubscribers (in unnamed module.....
On another note, the class you've mentioned seems to be packaged internal to the java.net.http module and should not be relied upon from your code. You must implement your own subscriber even if you desire a similar functionality as the code you're looking at. Since the module wouldn't be exporting it for a public use anyway.
You shouldn't use directly any class from any jdk.internal.* package. Have you tried using the public API HttpResponse.BodySubscribers.ofByteArray() instead?