Reputation: 4331
I have a simple JavaFX application and I want to create an installer for Windows machines. The javafx-maven-plugin
works and create an executable file of the application along with a Windows installer, but the problem is that, it creates a Windows installer with the JavaFX application inside and the complete JRE too.
So, how can I make to build the native files for Windows with the javafx-maven-plugin
without carrying the complete Java framework in it. Perhaps it should create only a depedency to the Java Framework. This bloats the installer from 1.5MB to 200MB of disk space.
With Maven I use the command mvn clean compile jfx:build-jar jfx:native
to get the native files in Windows and here is the POM file I am using:
<?xml version="1.0"?>
<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.demo</groupId>
<artifactId>hello-javafx-maven-example</artifactId>
<name>JavaFX Example Maven Project</name>
<organization>
<name>Jaa Demo</name>
</organization>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.1.3</version>
<configuration>
<mainClass>com.demo.helloWorld</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
Upvotes: 4
Views: 3575
Reputation: 2858
I'm the maintainer of that javafx-maven-plugin.
When creating your installer, it is "by design" that the JRE is bundled within your application. I myself stumbled upon this too, but in despite of the current documentation of oracle, I found it not possible to run my generated files (using JDK 1.8u40 and above, Windows) without having that JRE aside of my native launcher. The packager.dll seems to require it to be there. But to make it clear: this may be just a problem for me, not verified it nor did I investigate this.
To answer your question: you can remove the JRE by passing some bundleArguments:
<bundleArguments>
<runtime />
</bundleArguments>
I'm doing this myself, mostly to speed up test-projects, like here: https://github.com/javafx-maven-plugin/javafx-maven-plugin/blob/master/src/it/03-cli-jfx-native/pom.xml#L31
EDIT: please consider of upgrading to plugin-version 8.1.5 since there are some bugs fixed including a (IMHO) serious workaround for native launchers on linux-systems. Also there is support for creating bundles while normal maven-lifecycle: https://github.com/javafx-maven-plugin/javafx-maven-plugin/blob/master/src/it/07-lifecycle-build-jfx-native/pom.xml
Upvotes: 6