简体   繁体   English

Mac OSX上Java 10辅助启动器的替代方案是什么?

[英]What's the alternative of a Java 10 secondary launcher on Mac OSX?

I'm using Maven to build a JavaFx project on Windows and Mac. 我正在使用Maven在Windows和Mac上构建JavaFx项目。 I'm using Maven-ant-plugin to build my package and my build.xml contains several fx:secondaryLauncher blocks.Secondary launchers enable you to create additional executables inside your app directory that will launch classes other than your main class. 我正在使用Maven-ant-plugin构建我的包,我的build.xml包含几个fx:secondaryLauncher块。辅助启动器使您能够在app目录中创建其他可执行文件,这些可执行文件将启动除主类之外的类。

Here is a sample from the official documentation: 以下是官方文档中的示例:

<fx:info title="Test Suite"/>

<fx:secondaryLauncher
    mainClass="samples.TestSuite"
    name="Suite Applications"/>
    shortcut="true"/>

<fx:secondaryLauncher name="Editor">
    <fx:bundleArgument arg="icon" value="../resources/editor.ico"/>
</fx:secondaryLauncher>

<fx:secondaryLauncher name="Spreadsheet">
    <fx:bundleArgument arg="icon" value="../resources/spreadsheet.ico"/>
</fx:secondaryLauncher>

When I switched from Java 8 to Java 10 - the package that maven creates via the maven-ant-plugin stopped creating the secondary launchers on Mac OSX. 当我从Java 8切换到Java 10时 - maven通过maven-ant-plugin创建的软件包停止在Mac OSX上创建辅助启动器。 The fx:secondaryLauncher blocks seem to be ignored by the packager. 包装器似乎忽略了fx:secondaryLauncher块。

The Windows package DOES contain the secondary launchers and after researching a bit I found out that since Java 9 was released - "Multiple entry points are supported only for Windows and Linux applications" (full documentation here : https://docs.oracle.com/javase/9/deploy/self-contained-application-packaging.htm#JSDPG1000 ). Windows程序包包含辅助启动程序,经过研究后我发现自Java 9发布以来 - “仅支持Windows和Linux应用程序的多个入口点” (完整文档: https//docs.oracle.com /javase/9​​/deploy/self-contained-application-packaging.htm#JSDPG1000 )。

Does anyone have an idea about a good alternative to secondary launchers ? 有没有人知道二次发射器的好替代品? I would prefer to minimize the differences between Windows and Mac OSX build process (although it might not be able to this time ;-) ) Thanks! 我宁愿最小化Windows和Mac OSX构建过程之间的差异(虽然这次可能无法;-))谢谢!

After researching several possible solutions it looks like the following solution is the best one : 在研究了几种可能的解决方案后,看起来以下解决方案是最好的解决方案:

  1. specify a "strip-native-commands" attribute with the value "false" in the fx:runtime block of hte fx:deploy xml block. 在hte fx:deploy xml块的fx:runtime块中指定值为“false”的“strip-native-commands”属性。 this means that your application package will include the main java executables in your self-contained inatallation package. 这意味着您的应用程序包将在自包含的安装包中包含主要的java可执行文件。
  2. Instead of invoking the secondary launcher executables which no longer exist - activate the classes that the executables invoked directly (eg running java -cp . 而不是调用不再存在的辅助启动程序可执行文件 - 激活可执行文件直接调用的类(例如,运行java -cp。

this has several benefits : 这有几个好处:

  1. Minimal changes to the code/pom/build.xml . 代码/ pom / build.xml的最小更改。
  2. No dependency on a user-installed JRE because you use the JRE installed as part of your application installation. 不依赖于用户安装的JRE,因为您在应用程序安装过程中使用了JRE。

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

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