5

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">
helloworld
  • 166
  • 1
  • 2
  • 9
  • Edit the question to describe what you did or at least link to a resource that describes it. Provide full details of your environment (version info for: IDE, JavaFX, JDK, OS). Provide a [mcve] so the error can be replicated by copy and paste without change or addition. Provide context on why you are trying to do this and what you expect the output to be. – jewelsea Apr 19 '22 at 19:24
  • Please don't post duplicates of your own question. – jewelsea Apr 19 '22 at 19:44
  • 2
    I reopened your question, but there is no need for personal attacks. – jewelsea Apr 19 '22 at 21:38
  • @jewelsea Absoloutely not personal attack/s. Just stating my opinion about your actions. Updated my question with more information that you've required. – helloworld Apr 19 '22 at 22:33

2 Answers2

7

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.

jewelsea
  • 150,031
  • 14
  • 366
  • 406
  • So, I might be wrong, but as I can notice it's better to start new project and code everything again? – helloworld Apr 19 '22 at 22:59
  • 1
    It is only your build and packaging which is broken, not all your code, what you choose to do is up to you. – jewelsea Apr 19 '22 at 23:06
  • 1
    Personally, I would [create a new project in Idea](https://www.jetbrains.com/help/idea/javafx.html), then copy the code into the new project, ensure it works, then learn how to package it either as a [runnable exe](https://stackoverflow.com/questions/69811401/how-to-create-a-standalone-exe-in-java-that-runs-without-an-installer-and-a-jr), or [jlink zip](https://github.com/openjfx/javafx-maven-plugin#javafxjlink-options) or as an [installed app](https://github.com/dlemmermann/JPackageScriptFX). – jewelsea Apr 19 '22 at 23:06
  • Thanks for your help and answer. I appreciate it. – helloworld Apr 19 '22 at 23:07
  • 1
    unfortunatelly this method doesnt work anymore, i have a java8 project with many dependencies and it is a pain to convert it to java19. The decisions of the java team made javafx a problematic technology to deploy... – firephil Dec 23 '22 at 17:33
0

I faced the same problem when trying to run a project I built using Java 8 with Java 19 .

What you can do is download Java 8 and add it to your Netbeans as a new Java Platform, it will have JavaFX packages present and you wont need to set up JavaFX libs separately.

You can Download the Java 8 JDK from https://www.azul.com/downloads/
in the Java package selection chose JDK FX

Hassan A
  • 49
  • 3