Issue
I'm working on Netbeans 12 maven JavaFX 14.0.1 application.
The application is something like a theme viewer loading css files.
I want to capture Warnings (Errors) of the css 'StyleManager' so I can warn the user as it was proposed on this solution
StyleManager.errorsProperty().addListener((ListChangeListener<? super CssError>) c -> {
while (c.next()) {
for (CssError error : c.getAddedSubList()) {
// maybe you want to check for specific errors here
System.out.println(error.getMessage());
}
}
});
The problem is that com.sun.javafx.css.StyleManager is not exported so I get the error:
(package com.sun.javafx.css is declared in module javafx.graphics, which does not export it to module com.johntor.app)
I tried adding
--add-exports javafx.graphics/com.sun.javafx.css=com.johntor.app
without any luck!
Before this the application was working fine!!!
Any Ideas/Suggestions are more than welcome
EDIT: I included my pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.johntor</groupId>
<artifactId>ThemeViewer3</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>ThemeViewer3</name>
<url>http://www.greek-developers.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>14</maven.compiler.source>
<maven.compiler.target>14</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>14.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>14</release>
<mainClass>com.johntor.App</mainClass>
<compilerArgs>
<arg>--add-exports=javafx.graphics/com.sun.javafx.css=com.johntor.app</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<compilerArgs>
<arg>--add-exports</arg>
<arg>javafx.graphics/com.sun.javafx.css=com.johntor.app</arg>
</compilerArgs>
<mainClass>com.johntor.app.App</mainClass>
<options>
<option>--add-opens</option>
<option>javafx.controls/javafx.scene.control=com.johntor.app</option>
<option>--add-exports</option>
<option>javafx.graphics/com.sun.javafx.css=com.johntor.app</option>
<option>--add-exports</option>
<option>javafx.graphics/com.sun.javafx.css=ALL-UNNAMED</option>
</options>
</configuration>
<executions>
<execution>
<id>default-cli</id>
<configuration>
<mainClass>com.johntor.app.App</mainClass>
<options>
<option>--add-opens</option>
<option>javafx.controls/javafx.scene.control=com.johntor.app</option>
<option>--add-exports</option>
<option>javafx.graphics/com.sun.javafx.css=com.johntor.app</option>
</options>
<stripDebug>true</stripDebug>
<compress>2</compress>
<noHeaderFiles>true</noHeaderFiles>
<noManPages>true</noManPages>
<launcher>${project.artifactId}</launcher>
<jlinkImageName>../Deploy</jlinkImageName>
<!--<jlinkZipName>${project.artifactId}</jlinkZipName>-->
</configuration>
</execution>
<execution>
<id>debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=localhost:8000</option>
</options>
</configuration>
</execution>
<execution>
<id>ide-debug</id>
<configuration>
<options>
<option>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address}</option>
</options>
</configuration>
</execution>
<execution>
<!--Configuration for automatic IDE profiling-->
<id>ide-profile</id>
<configuration>
<options>
<option>${profiler.jvmargs.arg1}</option>
<option>${profiler.jvmargs.arg2}</option>
<option>${profiler.jvmargs.arg3}</option>
<option>${profiler.jvmargs.arg4}</option>
<option>${profiler.jvmargs.arg5}</option>
</options>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.fxml</include>
<include>**/*.css</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
<include>**/*.png</include>
<include>**/*.css</include>
<include>**/*.properties</include>
</includes>
</resource>
<resource>
<directory>.</directory>
<includes>
<include>readme.txt</include>
</includes>
</resource>
</resources>
</build>
</project>
Thank you in advance,
J!
Solution
Here is my pom that works for a very simple javafx maven project.
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<groupId>org.example</groupId>
<artifactId>MavenFxied</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>14.0.1</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>14.0.1</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>11</release>
<compilerArgs>
<arg>--add-exports=javafx.graphics/com.sun.javafx.css=mavenfxied</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.4</version>
<configuration>
<mainClass>example.Main</mainClass>
<options>
<option>--add-exports</option>
<option>javafx.graphics/com.sun.javafx.css=mavenfxied</option>
<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.css=mavenfxied</option>
</options>
</configuration>
</plugin>
</plugins>
</build>
</project>
I was able to build with mvn package
and run the project with mvn javafx:run
.
My module is named 'mavenfxied' and my package is 'example'.
Answered By - matt