i am using javafx for the first time and i get an error when i run a simple program :
Error occurred during initialization of boot layer
java.lang.module.FindException: Hash of javafx.base (29158284a7e9fd7c1303a1b262a5541913ebab69892ff25cf59db511cd7a6eca) differs to expected hash (fffde8f0d0c19d6a82793cd0bef8c93e0a518106b36a82844c60228bf7a134ee) recorded in java.base
I have watched many youtube tutorials but none of them show the error that i get. I also created a module-info.java :
module javafx {
requires javafx.fxml;
requires javafx.controls;
opens sample;
}
I am using the 11.0.4 java version and i recently downloaded javafx 15.
If anyone knows the solution to this problem would be very helpful :)
Related
I am having an issue setting up the module.info file for my java desktop app, I am using object box desktop as a database, so I am stuck at this error, I am using maven.
java: the unnamed module reads package io.objectbox.converter from both objectbox.java and objectbox.java.api
at times after edits I get a similar error
java: the com.app module reads package io.objectbox.converter from both objectbox.java and objectbox.java.api
so I an stuck in what may seems to be a loop .
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 have the following problem:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found
When I try to run the default class of JavaFX project which send a "Hello World" button, I'm using Netbeans 11.1 as my IDE, the JDK 13, Jre-8u221. I create the library Java Fx and added it to the module path inn the properties of my project and on VM on run options included the command --add-modules javafx.controls, javafx.graphics.
You need to add the module-info.java file in the same package as the class that contains the Main method. Inside this file (and implicitly inside the module definition block), there should be at least 1 line:
requires javafx.controls;
This should fix your problem.
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.