3

I am trying to build apache cassandra project, following(this). I have jdk 11 on my mac machine. When I run 'ant' command, I get error:

% ant
Buildfile: ..../cassandra/build.xml
Java 15 has removed Nashorn, you must provide an engine for running JavaScript yourself. GraalVM JavaScript currently is the preferred option.

BUILD FAILED
..../cassandra/build.xml:152: Unable to create javax script engine for javascript

What is a good workaround for this issue?

polo-language
  • 826
  • 5
  • 13
Mandroid
  • 6,200
  • 12
  • 64
  • 134

2 Answers2

1

Sorry this might not be the best answer, but I was having the same issue, and I am replying in hopes to unstuck you while a better answer comes along( I'd love to have a better understanding of why this is happening)

If you installed Maven via Homebrew you are probably using a different JDK version than the one set on JAVA_HOME.

You can run mvn -version to confirm. In my case I got this:

Apache Maven 3.8.4 (9b656c72d54e5bacbed989b64718c159fe39b537)
Maven home: /opt/homebrew/Cellar/maven/3.8.4/libexec
Java version: 17.0.1, vendor: Homebrew, runtime: /opt/homebrew/Cellar/openjdk/17.0.1_1/libexec/openjdk.jdk/Contents/Home
Default locale: en_MX, platform encoding: UTF-8

Notice that the Java version is set to open jdk17, while JAVA_HOME is set to 11 in my case.

What I did to force maven run my JAVA_HOME version was to use:

JAVA_HOME=$JAVA_HOME mvn clean install

That is all I had to do in order to fix ant's Unable to create javax script engine for javascript

I was working a different project( not cassandra) but your question resembles a lot both my environment and the debug output I was getting.

Again, hopefully this reply would generate some activity and someone with more experience in Maven could provide a much better input than I.

Hope this helps anyone having a similar issue.

0

Nashorn remains available as OpenJDK Nashorn, a standalone library. It is published on Maven Central so you can easily pull it in as a dependency for your Maven project.

Attila Szegedi
  • 4,405
  • 26
  • 24