"Unable to create javax script engine for javascript" 尝试创建 EXE 文件时出错

"Unable to create javax script engine for javascript" error when trying to create EXE file

我在尝试使用 Netbeans 13 生成 .exe 文件时遇到了这个问题。 (打包为 -> exe 安装程序)

完整错误:

C:\Users\*\Documents\NetBeansProjects\*\nbproject\build-native.xml:428: The following error occurred while executing this line:
C:\Users\*\Documents\NetBeansProjects\*\nbproject\build-native.xml:436: Unable to create javax script engine for javascript
BUILD FAILED (total time: 4 seconds)

有谁知道这里似乎有什么问题以及如何解决它?

更新:

OS: Windows 10

JavaFX: javafx-sdk-17.0.2

JDK: jdk-17.0.2

我在期待什么?

实际上没有必要发布代码,因为构建项目和 运行 项目本身进行得很顺利(没有错误)。尝试使用 Package As -> EXE Installer 生成 .exe 安装程序文件后出现问题(如图所示):

您可以返回查看完整错误,当我打开 build-native.xml 文件时,它指向这些代码行:

  <target name="-jfx-copylibs" depends="init,compile,-pre-pre-jar,-pre-jar,-jfx-copylibs-warning" unless="fallback.no.javascript">
        <jfx-copylibs-js-impl/>
    </target>
    <target name="-jfx-copylibs-warning" if="fallback.no.javascript">
        <echo message="Warning: Dependent Libraries copy (-jfx-copylibs) skipped in fallback build mode due to JDK missing JavaScript support."/>
    </target>
    <macrodef name="jfx-copylibs-js-impl">
        <sequential>
            <local name="run.classpath.without.build.classes.and.dist.dir"/>
            <pathconvert property="run.classpath.without.build.classes.and.dist.dir">
                <path path="${run.classpath}"/>
                <map from="${basedir}${file.separator}${build.classes.dir}" to=""/>
                <map from="${basedir}${file.separator}${dist.jar}" to=""/>
                <scriptmapper language="javascript">

第428行是:

<target name="-jfx-copylibs" depends="init,compile,-pre-pre-jar,-pre-jar,-jfx-copylibs-warning" unless="fallback.no.javascript">
        <jfx-copylibs-js-impl/>

第 436 行是:

    <pathconvert property="run.classpath.without.build.classes.and.dist.dir">

您尝试做的事情根本不会按照您尝试做的方式工作:

  1. 作为 EXE 工具的 NetBeans 包(当前)已过时。

  2. 它不适用于现代 Java 和 JavaFX 版本。

  3. 它使用 JDK 中的 Java 脚本,该脚本已从 JDK 15 中的 JDK 中删除。

  4. 它使用JDK中的javafxpackager tool and ant javafx tasks which no longer exist in the JDK and were replaced by jpackage 16.

  5. 它依赖于将 JavaFX 打包在类路径上的一个大 jar 中,这是自 Java 11 移除 JavaFX 后不受支持的执行配置来自 Oracle JDK 发行版并作为一组模块分发。

  6. 它依赖于现已过时的第 3 方 Wix 和 InnoSetup 软件版本。

documentation for the NetBeans export to EXE feature 状态:

This tutorial needs a review. You can open a JIRA issue, or edit it in GitHub following these contribution guidelines.

它需要审查的原因是该功能将无法像当前在最近的 Java 和 JavaFX 版本的 NetBeans 中实现的那样工作。它可能适用于来自 Oracle 的过时 Java 8 版本,如果您可以获得兼容的第 3 方软件来支持它的使用。您可能需要编写您的应用程序以使用 Oracle Java 8 和 IDE 以及在 Oracle Java 8 下 运行 的应用程序构建过程(这可能是不可能的对于最近的 NetBeans 版本)。

对于备选方案,请研究 packaging resources in the JavaFX tag