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

Time:04-20

I've came across this problem while trying to generate .exe file by using Netbeans 13. (Package as -> exe installer)

Full error:

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)

Does anyone know what seems to be problem here and how to fix it?

UPDATE:

OS: Windows 10

JavaFX: javafx-sdk-17.0.2

JDK: jdk-17.0.2

What am I expecting?

  • I am expecting .exe file

There's no need really for posting code because building project and running project itself goes smoothly (without the errors). The problem occurs after trying to generate .exe installer file by using Package As -> EXE Installer (as shown in image):Actions taken

You can go back to see Full error and when I open build-native.xml file it points me to these lines of code:

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

Where line 428 is:

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

And where line 436 is:

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

CodePudding user response:

What you are trying to do is simply not going to work in the way you are trying to do it:

  1. The NetBeans Package as EXE facility is (currently) obsolete.

  2. It will not work with modern Java and JavaFX versions.

  3. It uses JavaScript from the JDK which was removed from the JDK in JDK 15.

  4. It uses the javafxpackager tool and ant javafx tasks which no longer exist in the JDK and were replaced by jpackage in JDK 16.

  5. It relies on JavaFX being packaged in one large jar on the classpath, which is an unsupported execution configuration since Java 11 when JavaFX was removed from the Oracle JDK distribution and distributed as a set of modules.

  6. It relies on versions of 3rd party Wix and InnoSetup software that are now obsolete.

The documentation for the NetBeans export to EXE feature states:

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

The reason it needs a review is that the feature will not work as currently implemented in NetBeans for recent Java and JavaFX versions. It may work for obsolete Java 8 versions from Oracle, if you can get a hold of the compatible 3rd party software to support its usage. You would likely need both your app to be written to use Oracle Java 8 and the IDE and application build process to run under Oracle Java 8 (which might not be possible for recent NetBeans versions).

For alternatives, study the packaging resources in the JavaFX tag.

  • Related