How to create a fat jar for my JavaFX program?

Julian Jupiter julianjupiter.io at gmail.com
Mon Jul 20 04:52:44 UTC 2020


I'm using maven-shade-plugin:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<createDependencyReducedPom>true</createDependencyReducedPom>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation=
"org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>package.to.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>

On Mon, Jul 20, 2020, 5:32 AM Davide Perini, <perini.davide at dpsoftware.org>
wrote:

> Hi all,
> thanks for the great project, I love JavaFX.
>
> I always used the maven plugin to crete fat jars with all my deps. The
> resulting jar is an executable one and ready to use.
>
> This is my pom that create the fat jar.
>
> but when I try to exceute the jar I get this error:
>
> Error: JavaFX runtime components are missing, and are required to run
> this appli
> cation
>
>
> if I explode the fat jar I can see that there are the javafx class in
> it. what am I doing wrong?
>
> Thanks
> Davide
>
> <plugin> <groupId>org.openjfx</groupId>
> <artifactId>javafx-maven-plugin</artifactId>
> <version>${javafx.maven.plugin.version}</version> <configuration>
> <mainClass>org.dpsoftware.FastScreenCapture</mainClass> </configuration>
> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-assembly-plugin</artifactId> <configuration>
> <outputDirectory>${project.build.directory}/</outputDirectory>
> <finalName>JavaFastScreenCapture</finalName> </configuration> <executions>
> <execution> <id>make-executable-jar-with-dependencies</id>
> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration>
> <archive> <manifest> <addClasspath>true</addClasspath>
> <mainClass>org.dpsoftware.FastScreenCapture</mainClass> </manifest>
> </archive> <descriptorRefs>
> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs>
> </configuration> </execution>
> </executions> </plugin>
>
>


More information about the openjfx-dev mailing list