0

I am new to Maven. I need to include

private javafx.embed.swing.JFXPanel jFXPanel1;

To a new project with uses Maven + Jigsaw modules.

I have the following problem with javafx.embed.swing package.

Problem

I thought that adding this dependency would work, but it does not.

<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-swing -->
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-swing</artifactId>
    <version>19</version>
</dependency>

On clean install, I see the following

(package javafx.embed.swing is declared in the unnamed module, but module com.my.module does not read it)

enter image description here

I don't understand this. I see that JAR, it only has a manifest file, and no .class files, which confuses me even more.

If I look in the m2 folder, I see a different JAR with the same prefix, but with win suffix and there I see the package.

I think this is the classifier

<classifier>${javafx.platform}</classifier>

And I think, but I don't know, if this jar is being picked by Maven or not, but it seems it is not, because I don't see it in the IntelliK libraries.

enter image description here

enter image description here

enter image description here

enter image description here

I don't have any problem with JavaFX, everything is modular out there and is working. I have the problem only with this jar.

-----------------------------UPDATE-----------------------------------

The culprit here was IntellijIdea i did click on File->Invalidate caches later restart it. Later i could see the dependency loaded.

Dependency loaded.

Later i could add the module Added module

dependency loaded.

And i can see now the dependency and that's it. Thanks.

chiperortiz
  • 4,751
  • 9
  • 45
  • 79
  • 4
    The module is called `javafx.swing`, not `javafx.embed.swing`. – James_D Jan 19 '23 at 16:08
  • 2
    Don’t use `ea` version software. Use a recent stable release, not an obsolete early access release. For JavaFX, that is currently `19.0.2`. And don’t mix versions of JavaFX software, use the exact same version for all JavaFX dependencies. – jewelsea Jan 20 '23 at 08:43

1 Answers1

5

Just declaring a Maven dependency is simply not enough. You also have to make the Java module system happy. You have to declare this additional dependency in your module-info.java file of your project too. Javas module system knows nothing about Maven dependencies.

mipa
  • 10,369
  • 2
  • 16
  • 35