r/JavaFX • u/5oco • Apr 10 '25
Help Module javafx.controls not found
I'm trying to package and build my javafx application but I'm having problems with the jlink step. I keep getting errors saying they can't find modules. I'm using java sdk21 and javafx, jdbc(for connecting to sql database), and itext7(for generating pdfs) Any help would be appreciated before I post on StackOverflow and get yelled at for doing something wrong.
This is my line I'm running
jlink --module-path "$env:PATH_TO_JAVAFX;$env:PATH_TO_FX_MODS;$env:PATH_TO_JDBC;target/classes" --add-modules com.autoshop.oc_autoshop,javafx.controls,javafx.fxml,jave.base --output myruntime --strip-debug --no-man-pages --no-header-files
This is my module-info class
module com.autoshop.oc_autoshop {
requires javafx.controls;
requires javafx.fxml;
requires java.sql;
requires io;
requires kernel;
requires layout;
opens com.autoshop.oc_autoshop to javafx.fxml;
exports com.autoshop.oc_autoshop;
}
I feel like there's a problem with the environment variables.
PATH_TO_FX_MODS --> C:\Program Files\Java\javafx-sdk-21.0.6\jmods
PATH_TO_JAVAFX --> C:\Program Files\Java\java-sdk-21.0.6
PATH_TO_JDBC --> C:\Documents\Jars
I ran "mvn clean package" and "mvn clean install"
And here's 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.autoshop</groupId>
<artifactId>OC_AutoShop</artifactId>
<version>1.0-SNAPSHOT</version>
<name>OC_AutoShop</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.9.2</junit.version> </properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>21</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itext-core</artifactId>
<version>8.0.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<configuration>
<mainClass>com.autoshop.oc_autoshop.Launcher</mainClass>
</configuration>
<executions>
<execution>
<!-- Default configuration for running with: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<launcher>app</launcher>
<jlinkZipName>app</jlinkZipName>
<jlinkImageName>app</jlinkImageName>
<noManPages>true</noManPages>
<stripDebug>true</stripDebug>
<noHeaderFiles>true</noHeaderFiles>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
View all comments
Show parent comment
1
u/Capaman-x Apr 11 '25
JavaFX used to be included in the JDK. They took it out in Java 11. Then Oracle changed some licensing terms which caused many companies to create their own JDK's. Some of those companies include a version of the JDK with JavaFX included. This is what I mean by full JDK. Below is a link to where you can get one. Make sure to download the "full" for whatever architecture you are targeting.
https://bell-sw.com/pages/downloads/#jdk-21-lts