Wrapping into native container:
For Wrapping your application into an EXE or DEB, or..., you should not use launch4j, but "jpackage". It is the official tool from oracle for wrapping JARs into EXEs or DEBs, .. and it is included in JDK 17 LTS. It works like a charm. Please note: Your projects don't have to use JDK 17, they can use JDK 11 as well.
General about JFX:
I can't tell you why, but JFX does NOT like it, if the class, which contains the main() extends from another class. It took me hours to find that out. It may sound stupid, uneccessary or similiar, but I can only advise you to do this workaround:
Mainclass:
package com.wedasoft.FxMultiMessageSender;
public class FxMultiMessageSenderMain {
public static void main(String[] args) {
App.main(args);
}
}
JFX-Application-Starting-Class:
package com.wedasoft.FxMultiMessageSender;
public class App extends Application {
public static final String APPLICATION_NAME = "xxxxxxxx";
private Stage primaryStage;
private Scene primaryScene;
public static void main(String[] args) {
//createDatabase();
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
System.out.println("Starting " + APPLICATION_NAME);
}
}
Not really working JARs:
Your question sounds like you are using a normal Java project and embedded the JFX libraries. If so, I can only advise you to use Maven or Gradle for at least JFX projects; you won't get happy without one of them.
If you use Maven, then try to integrated your pom.xml with the following pom.xml. You do not need to specify any VM arguments. You need to adjust the main class <mainClass>com.wedasoft.FxMultiMessageSender.FxMultiMessageSenderMain</mainClass> in the javafx-maven-plugin and in the maven-shade-plugin.
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.wedasoft</groupId>
<artifactId>FxMultiMessageSender</artifactId>
<version>0.0.2</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<javafx.version>17</javafx.version>
</properties>
<dependencies>
<!-- javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>11</release>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.8</version>
<executions>
<execution>
<!-- Default configuration for running -->
<!-- Usage: mvn clean javafx:run -->
<id>default-cli</id>
<configuration>
<mainClass>com.wedasoft.FxMultiMessageSender.FxMultiMessageSenderMain</mainClass>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.wedasoft.FxMultiMessageSender.FxMultiMessageSenderMain</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>