Trouble linking module to javafx.base - java

Receiving error when running application
module javafx.base cannot access class Model.Country (in module rbrod.scheduleapp) because module rbrod.scheduleapp does not open Model to javafx.base
File Structure:
main >
java >
Controller
Database
DBAccess
Model
rbrod.scheduleapp
resources >
fxml
module-info.java structure
module rbrod.scheduleapp {
requires javafx.controls;
requires javafx.fxml;
requires java.sql;
requires mysql.connector.j;
opens rbrod.scheduleapp to javafx.fxml;
opens Controller to javafx.fxml;
opens Model to javafx.fxml;
exports rbrod.scheduleapp;
}
Tried adding "opens Controller to javafx.fxml" amd "opens Model to javafx.fxml" to module-info.java

Related

Java Modules - Adding modules, but not everything from it?

I have a simple Spring Boot application, described here
Java Modules - Simple Spring Boot application, create custom runtime
which isn't a modularized application (no module-info.java).
As described in that post, when creating a custom runtime image, to make that simple application run, I have to add the java.desktop module.
jlink --module-path $JAVA_HOME/jmods --add-modules java.desktop --output mycustomrt
When a module is added, must always the whole module be added, or can it be further reduced to just the needed/used packages (artifacts)?
Of course in that given command there is no direct association to my simple application, so it would be logical that the whole java.desktop module is included, also it's transitive declared modules.
But looking into the documentation at
https://docs.oracle.com/en/java/javase/19/docs/api/java.desktop/module-summary.html
I see, that java.desktop contains a lot of packages that my simple application doesn't need
exports java.applet
exports java.awt
exports java.awt.color
exports java.awt.desktop
exports java.awt.dnd
exports java.awt.event
exports java.awt.font
exports java.awt.geom
exports java.awt.im
exports java.awt.im.spi
exports java.awt.image
exports java.awt.image.renderable
exports java.awt.print
exports java.beans
exports java.beans.beancontext
exports javax.accessibility
exports javax.imageio
exports javax.imageio.event
exports javax.imageio.metadata
exports javax.imageio.plugins.bmp
exports javax.imageio.plugins.jpeg
exports javax.imageio.plugins.tiff
exports javax.imageio.spi
exports javax.imageio.stream
exports javax.print
exports javax.print.attribute
exports javax.print.attribute.standard
exports javax.print.event
exports javax.sound.midi
exports javax.sound.midi.spi
exports javax.sound.sampled
exports javax.sound.sampled.spi
exports javax.swing
exports javax.swing.border
exports javax.swing.colorchooser
exports javax.swing.event
exports javax.swing.filechooser
exports javax.swing.plaf
exports javax.swing.plaf.basic
exports javax.swing.plaf.metal
exports javax.swing.plaf.multi
exports javax.swing.plaf.nimbus
exports javax.swing.plaf.synth
exports javax.swing.table
exports javax.swing.text
exports javax.swing.text.html
exports javax.swing.text.html.parser
exports javax.swing.text.rtf
exports javax.swing.tree
exports javax.swing.undo
Applet, AWT, Swing, also something regarding sound, which definitely isn't needed.

Module not found: javafx.web

I wanted to create a WebView with Javafx, and I added requires javafx.web; to my module-info.jar, but IntelliJ say: "Module not found: javafx.web".
requires javafx.controls;
requires javafx.fxml;
requires javafx.base;
requires javafx.graphics;
works without any problem.
What can I do?
Have you also added a dependency to javafx-web in Maven/Gradle or added the corresponding jar file to your build?

Modules not found when trying to inject module-info.java

I have a JavaFX project that uses Apache's PDFBox. I want to use JLink to build a JRE of it, but I can't since PDFBox is an automodule. Thus, I'm trying to inject a module-info file in it.
I generated this module-info file using jdeps:
module org.apache.pdfbox {
requires org.bouncycastle.pkix;
requires org.bouncycastle.provider;
requires transitive commons.logging;
requires transitive java.desktop;
requires transitive java.xml;
requires transitive org.apache.fontbox;
exports org.apache.pdfbox.contentstream;
exports org.apache.pdfbox.contentstream.operator;
exports org.apache.pdfbox.contentstream.operator.color;
exports org.apache.pdfbox.contentstream.operator.graphics;
exports org.apache.pdfbox.contentstream.operator.markedcontent;
exports org.apache.pdfbox.contentstream.operator.state;
exports org.apache.pdfbox.contentstream.operator.text;
exports org.apache.pdfbox.cos;
exports org.apache.pdfbox.filter;
exports org.apache.pdfbox.io;
exports org.apache.pdfbox.multipdf;
exports org.apache.pdfbox.pdfparser;
exports org.apache.pdfbox.pdfwriter;
exports org.apache.pdfbox.pdmodel;
exports org.apache.pdfbox.pdmodel.common;
exports org.apache.pdfbox.pdmodel.common.filespecification;
exports org.apache.pdfbox.pdmodel.common.function;
exports org.apache.pdfbox.pdmodel.common.function.type4;
exports org.apache.pdfbox.pdmodel.documentinterchange.logicalstructure;
exports org.apache.pdfbox.pdmodel.documentinterchange.markedcontent;
exports org.apache.pdfbox.pdmodel.documentinterchange.prepress;
exports org.apache.pdfbox.pdmodel.documentinterchange.taggedpdf;
exports org.apache.pdfbox.pdmodel.encryption;
exports org.apache.pdfbox.pdmodel.fdf;
exports org.apache.pdfbox.pdmodel.font;
exports org.apache.pdfbox.pdmodel.font.encoding;
exports org.apache.pdfbox.pdmodel.graphics;
exports org.apache.pdfbox.pdmodel.graphics.blend;
exports org.apache.pdfbox.pdmodel.graphics.color;
exports org.apache.pdfbox.pdmodel.graphics.form;
exports org.apache.pdfbox.pdmodel.graphics.image;
exports org.apache.pdfbox.pdmodel.graphics.optionalcontent;
exports org.apache.pdfbox.pdmodel.graphics.pattern;
exports org.apache.pdfbox.pdmodel.graphics.shading;
exports org.apache.pdfbox.pdmodel.graphics.state;
exports org.apache.pdfbox.pdmodel.interactive.action;
exports org.apache.pdfbox.pdmodel.interactive.annotation;
exports org.apache.pdfbox.pdmodel.interactive.annotation.handlers;
exports org.apache.pdfbox.pdmodel.interactive.annotation.layout;
exports org.apache.pdfbox.pdmodel.interactive.digitalsignature;
exports org.apache.pdfbox.pdmodel.interactive.digitalsignature.visible;
exports org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination;
exports org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline;
exports org.apache.pdfbox.pdmodel.interactive.form;
exports org.apache.pdfbox.pdmodel.interactive.measurement;
exports org.apache.pdfbox.pdmodel.interactive.pagenavigation;
exports org.apache.pdfbox.pdmodel.interactive.viewerpreferences;
exports org.apache.pdfbox.printing;
exports org.apache.pdfbox.rendering;
exports org.apache.pdfbox.text;
exports org.apache.pdfbox.util;
exports org.apache.pdfbox.util.filetypedetector;
}
At the jar's folder, I ran:
javac --patch-module org.apache.pdfbox=pdfbox-2.0.20.jar module-info.java
But then I got
pdfbox/module-info.java:2: error: module not found: org.bouncycastle.pkix
requires org.bouncycastle.pkix;
^
pdfbox/module-info.java:3: error: module not found: org.bouncycastle.provider
requires org.bouncycastle.provider;
^
pdfbox/module-info.java:5: error: module not found: commons.logging
requires transitive commons.logging;
^
pdfbox/module-info.java:8: error: module not found: org.apache.fontbox
requires transitive org.apache.fontbox;
^
4 errors
How can I fix this? Is there any better workaround? Thanks in advance.
The project: https://github.com/ajsaraujo/mre-automodule
You cannot use jlink directly because of the automatic module issue. But you can follow this tutorial https://github.com/dlemmermann/JPackageScriptFX which also uses jlink but only to create a dedicated runtime without having to modularize your project. I am also using PDFBox in my project, so I know it works. Disclaimer: I am biased because I am the co-author of the above mentioned tutorial :-)
I found a tutorial about making the module-info.class step by step.
It worked for me to create module-info.class for org.apache.commons.math3 .
https://www.youtube.com/watch?v=bO6f3U4i0A0&t=293
For me, the 'module not found' issue didn't show up.

JavaFX 11 OpenJDK module-info.java

Error:(1,1) java: module Reports reads package java.awt from both java.desktop and java.datatransfer
I'm clueless to this problem and how to fix it.
module-info.java is as follows:
module Reports {
requires javafx.graphics;
requires com.jfoenix;
requires javafx.fxml;
requires javafx.controls;
requires java.sql;
requires org.joda.time;
requires jna;
requires jna.platform;
requires java.datatransfer;
requires java.desktop;
}
My module-info.java looks like this:
module Alemungula {
requires javafx.graphics;
requires javafx.fxml;
requires javafx.controls;
opens sample;
}
I think you miss open statement where sample is your starter file.

Import PropertyValueFactory cannot be resolved

As the title says:
Somehow java can't find the PropertyValueFactory class, although it is in the system library (as seen in the picture at the link) and I've got no idea why.
Other classes from that package are working, just this specific one doesn't...
I'm using JDK 9.0.4 with Eclipse 4.7.3
import javafx.scene.control.cell.PropertyValueFactory;
module javafx.controls {
requires transitive javafx.base;
requires transitive javafx.graphics;
And here is module-info.class:
module javafx.controls {
requires transitive javafx.base;
requires transitive javafx.graphics;
exports javafx.scene.chart;
exports javafx.scene.control;
exports javafx.scene.control.cell;
exports javafx.scene.control.skin;
exports com.sun.javafx.scene.control to
javafx.web;
exports com.sun.javafx.scene.control.behavior to
javafx.web;
exports com.sun.javafx.scene.control.inputmap to
javafx.web;
exports com.sun.javafx.scene.control.skin to
javafx.graphics,
javafx.web;
}
Screen of the problem

Categories