Reputation: 45
Whenever I create a GraphicsContext object in my JavaFX application, it creates an error that reads:
The type GraphicsContext from module javafx.graphics may not be accessible to clients due to missing 'requires transitive'
Here's a small example of code which causes the warning/ error:
import javafx.scene.canvas.GraphicsContext;
public Factory(GraphicsContext gc) {
super();
this.gc = gc;
}
The GraphicsContext is underlined in the warning colour, and has 3 quick fixes suggested by eclipse. 2 of them include adding @SuppressWarnings which does not fix the problem at all and the other "Configure Problem Serverity" which I think just tells eclipse to not worry about the issue.
This code works perfectly when ran in eclipse but when I export as a runnable JAR file, the file closes immediately. I would like the classes to be accessible to clients as GraphicsContexts are funsamental to my application.
I also get the same error when I use the JavaFX class stage.
The type Stage from module javafx.graphics may not be accessible to clients due to missing 'requires transitive'
I am using eclipse and jdk-16
How/where in my program do I include 'requires transitive'? Or is there a differnt problem hidden by this warning?
Upvotes: 2
Views: 9761
Reputation: 7910
If you are set up as a modular project, you should have a module-info.java
file directly in your /src folder.
Here is an example of contents of a module-info.java file, from the openjfx.io Getting Started documentation:
As you can see, the word "transitive" was added to the line for javafx.graphics.
Upvotes: 10