I have been trying to fix this error for the past few hours but didn't manage to do so.
First of all, I created a Maven Project where I added the needed JavaFX dependencies (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>groupId</groupId>
<artifactId>STTGui</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<!-- Maven Plugin configuration is required, without it an internal java error is thrown -->
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<release>12</release>
</configuration>
</plugin>
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>speechToText.userInterface.MainEntry</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.3</version>
<configuration>
<mainClass>speechToText.userInterface.MainEntry</mainClass>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>maven-cognitiveservices-speech</id>
<name>Microsoft Cognitive Services Speech Maven Repository</name>
<url>https://csspeechstorage.blob.core.windows.net/maven/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.microsoft.cognitiveservices.speech</groupId>
<artifactId>client-sdk</artifactId>
<version>1.6.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>12.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-graphics -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>12.0.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12.0.2</version>
</dependency>
</dependencies>
</project>
I also added module-info.java:
module SSTGui {
requires javafx.controls;
requires javafx.fxml;
requires client.sdk;
opens speechToText.userInterface to javafx.fxml;
exports speechToText.userInterface;
}
When I execute the JavaFX
application inside my IDE all works fine, when I build a Jar using maven -> lifecycle ->package
the jar builds but when executing it I get the following error:
Error: JavaFX runtime components are missing, and are required to run this application
Idea:
1) Install OPENJDK
because Java JDK doesn't contain runtime components for JavaFX anymore -> Didn't result in any change.
2) Use the OpenJFX SDK
of GLUON instead of Maven, didn't solve it either, same problem.
I guess somehow that the dependencies get not packed in the JAR that's why it might now work, but I couldn't solve it, any idea?
EDIT I added `maven shade plugin to create a fat jar:
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>speechToText.userInterface.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
But after the built is finished and two jars are created: original-name.jar
and name.jar
When I execute the name.jar
I get the following error:
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
When executing original-name.jar
I get:
no main manifest attribute, in original-STTGui-1.0-SNAPSHOT.jar
To solve this I tried implementing a Helper main-class which doesn't extend from Application
which starts my native main:
package speechToText.userInterface;
public class MainEntry {
public static void main(String[] args) {
Main.main(args);
}
}
I also changed the <mainClass>
attribute in my maven-shade-plugin
to this class and also the attribute in javafx-plugin.