This relates to the problem discussed in Maven project fails to resolve JavaFX dependencies. It seemed old enough to ask again and the remedies discussed there haven't helped.
My mac: MacBook Pro with Apple M1 Max chip, macOS 15.2
Java: multiple versions are installed but
echo $JAVA_HOME
/opt/homebrew/Cellar/openjdk@21/21.0.6/libexec/openjdk.jdk/Contents/Home
and this version is aarch64
file $(echo $JAVA_HOME)/bin/java
/opt/homebrew/Cellar/openjdk@21/21.0.6/libexec/openjdk.jdk/Contents/Home/bin/java: Mach-O 64-bit executable arm64
Maven
which mvn
/opt/homebrew/bin/mvn
mvn -version
Apache Maven 3.9.9 (8e8579a9e76f7d015ee5ec7bfcdc97d260186937)
Maven home: /opt/homebrew/Cellar/maven/3.9.9/libexec
Java version: 21.0.6, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk@21/21.0.6/libexec/openjdk.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "15.2", arch: "aarch64", family: "mac"
pom.xml
<?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.drm.astro</groupId>
<artifactId>picker</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<javafx.platform>mac-aarch64</javafx.platform>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx</artifactId>
<version>21.0.6</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21.0.6</version>
</dependency>
<dependency>
<groupId>org.controlsfx</groupId>
<artifactId>controlsfx</artifactId>
<version>11.2.1</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>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
</plugin>
</plugins>
</build>
</project>
Running maven
mvn install
...
[ERROR] dependency: org.openjfx:javafx:jar:21.0.6 (compile)
[ERROR] Could not find artifact org.openjfx:javafx:jar:21.0.6 in central (https://repo.maven.apache.org/maven2)
I've tried different versions of openjfx:javafx and I've tried manually adding the property
<javafx.platform>mac-aarch64</javafx.platform>
to the pom. None of the javafx directories at Maven Central, like https://repo.maven.apache.org/maven2/org/openjfx/javafx/21.0.6, have jar files so I don't know where maven is supposed to resolve this dependency. Where are aarch64 jars so one can get them directly if the javafx-maven-plugin isn't working correctly?
You have the wrong artifact name. The javafx artifacts to use in your project should have a hyphenated name, not just javafx
.
Use:
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21.0.6</version>
Don’t specify the JavaFX platform in the pom.xml, the build system can work that out for you. If you specify the platform, the build is not portable.
Start with the openjfx maven sample or the IntelliJ Idea New JavaFX project wizard.
The javafx-maven-plugin
does not fetch JavaFX jars; it does other things, like creating jlink runtimes. You don’t need it unless you are doing that.
The standard Maven dependency mechanism fetches the JavaFX jar files from the Maven central repository. They are classified by platform and architecture type there.
https://repo1.maven.org/maven2/org/openjfx/javafx-controls/21.0.6/