简体   繁体   English

使用没有JRE的javafx-maven-plugin Maven + Build Native

[英]Maven + Build Native with javafx-maven-plugin without JRE

I have a simple JavaFX application and I want to create an installer for Windows machines. 我有一个简单的JavaFX应用程序,我想为Windows机器创建一个安装程序。 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 . javafx-maven-plugin与Windows安装程序一起工作并创建应用程序的可执行文件,但问题是,它创建了一个Windows安装程序,其中包含JavaFX应用程序和完整的JRE

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. 那么,如何使用javafx-maven-plugin为Windows构建本机文件,而无需在其中携带完整的Java框架。 Perhaps it should create only a depedency to the Java Framework. 也许它应该只创建一个Java Framework的依赖。 This bloats the installer from 1.5MB to 200MB of disk space. 这使安装程序从1.5MB到200MB的磁盘空间膨胀。

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: 使用Maven我使用命令mvn clean compile jfx:build-jar jfx:native来获取Windows中的本机文件,这里是我正在使用的POM文件:

<?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>

I'm the maintainer of that javafx-maven-plugin. 我是那个javafx-maven-plugin的维护者。

When creating your installer, it is "by design" that the JRE is bundled within your application. 在创建安装程序时,“按设计”是将JRE捆绑在应用程序中。 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. 我自己也偶然发现了这一点,但是尽管有oracle的当前文档,但我发现无法运行我生成的文件(使用JDK 1.8u40及更高版本,Windows)而没有将JRE放在我的本机启动器旁边。 The packager.dll seems to require it to be there. packager.dll似乎要求它在那里。 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来删除JRE:

<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 我自己这样做,主要是为了加速测试项目,比如: https//github.com/javafx-maven-plugin/javafx-maven-plugin/blob/master/src/it/03-cli- JFX-本地/ 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. 编辑:请考虑升级到插件版本8.1.5,因为有一些错误修复,包括(恕我办事)严重的解决方案在Linux系统上的本机启动器。 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 在正常的maven-lifecycle中也支持创建包: https//github.com/javafx-maven-plugin/javafx-maven-plugin/blob/master/src/it/07-lifecycle-build-jfx-native /pom.xml

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM