netbeans 尝试创建EXE文件时出现“无法为javascript创建javax脚本引擎”错误

iqih9akk  于 2022-11-10  发布在  Java
关注(0)|答案(1)|浏览(213)

我在尝试使用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)

有人知道这里的问题是什么吗?如何解决?
最新消息:
操作系统:Windows 10
JavaFX:Javaafx-sdk-17.0.2版本的软件开发工具
Java开发工具包:
我在期待什么?

  • 我需要.exe文件

实际上不需要发布代码,因为构建项目和运行项目本身都很顺利(没有错误)。问题发生在尝试使用Package As -〉EXE Installer生成.exe安装程序文件之后(如图所示):x1c 0d1x
您可以返回查看完整错误,当我打开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">
ugmeyewa

ugmeyewa1#

你试图做的事情根本不会以你试图做的方式工作:

  1. NetBeans得“包为EXE”工具(当前)已过时.
    1.它不适用于现代Java和JavaFX版本。
    1.它使用JDK中的JavaScript,而该JavaScript在JDK 15中已从JDK中删除。
    1.它使用的javafxpackager tool and ant javafx tasks在JDK中已不存在,在JDK 16中已被jpackage取代。
    1.它依赖于将JavaFX打包在类路径上的一个大jar中,这是一种自Java 11以来不受支持的执行配置,当时JavaFX已从Oracle JDK分发中删除并作为一组模块分发。
    1.它依赖于第三方Wix和InnoSetup软件的版本,这些版本现在已经过时。
    documentation for the NetBeans export to EXE feature声明:
    本教程需要审阅。您可以打开一个JIRA问题,或者在GitHub中按照以下投稿指南编辑它。
    之所以需要对其进行检查,是因为该特性在NetBeans中的当前实现方式不适用于最新的Java和JavaFX版本,如果您可以获得兼容的第三方软件来支持其使用。您可能需要将应用程序编写为使用OracleJava8,并需要在OracleJava8下运行IDE和应用程序构建过程(对于最新的NetBeans版本,这可能不可行)。
    对于替代方案,请研究packaging resources in the JavaFX tag

相关问题