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?
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.
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 :)
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 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.