4

I am using NetBeans 12.0. and windows 10 64 bit.My JDK is 15.0.2 and JavaFx SDK 16. When I try to build my javafx application it shows the following build error:

C:\Users\musta\OneDrive\Documents\NetBeansProjects\JavafxTry\nbproject\jfx-impl.xml:1251: The following error occurred while executing this line: C:\Users\musta\OneDrive\Documents\NetBeansProjects\JavafxTry\nbproject\jfx-impl.xml:1259: Unable to create javax script engine for javascript

BUILD FAILED (total time: 3 seconds)

Mustafa Iram
  • 41
  • 1
  • 1
  • 2

2 Answers2

1

The Nashorn JavaScript Engine has been removed in Java 15: https://openjdk.java.net/jeps/372

  • 1
    Thank you. But how can I fix this? i mean what I should I do? I am a beginner in Java help me please. Give me some details. It would be very nice. – Mustafa Iram Apr 06 '21 at 19:47
  • 1
    @MustafaIram There are several possibilities: 1. You could go back to Java 14 or older. 2. Replace the code that requires JavaScript. 3. Migrate to GraalVM: https://golb.hplar.ch/2020/04/java-javascript-engine.html –  Apr 07 '21 at 10:07
1

The javascript engine used to be included in the JVM but it has been removed in Java 15.

As an alternative you can use Groovy instead. Groovy looks similar to javascript. Your javascript should be easy to port to Groovy.

When you use the 'groovy-all jar', the script tag looks something like:

<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpath="path/to/groovy-all-2.4.21.jar" />
<groovy>
    // your Groovy script
</groovy>
R. Oosterholt
  • 7,720
  • 2
  • 53
  • 77
  • This isn't always going to help; The same error appears if trying to build pure-java applications, because it's coming from (what I presume are) Netbeans-generated build/configure files. I.e. users can encounter this even if they haven't touched a line of javascript. In which case the correct way of replacing/fixing Netbean's build files with Groovey is pretty unclear. – MRule Jun 03 '22 at 09:13