2

My purpose is to have a JSR-223 javascript engine available in the AdaptOpenJDK 8 VM.

So i thought to use the already familiar Rhino.

The OpenJDK wiki document here
https://wiki.openjdk.java.net/display/Nashorn/Using+Rhino+JSR-223+engine+with+JDK8

It specifies the place where to download Mozilla Rhino. here:
https://github.com/mozilla/rhino

And specifies there to download the jsr-223 script-engine wrapper. here:
https://java.net/projects/Scripting
But this link is dead.

Where can i can find the JSR-223 wrapper for Rhino?
Or maybe there is a better alternative available as JSR-223 javascript-engine.

Houtman
  • 2,819
  • 2
  • 24
  • 34
  • Did you consider Nashorn ? It pretty much replaced Rhino, and it might even be included in openjdk8. It is being removed from java >11 I think. – matt May 23 '19 at 09:13
  • yes i had. Nashorn was required for the HTML5 browser, which were both part of JavaFX. that is why OpenJDK8 does not have either, because JavaFX is not part of the JVM spec.(afaik) Java7 had Rhino, Java8 had Nashorn, OpenJDK8 has neither :-| – Houtman May 23 '19 at 09:50
  • I just download jdk8 from adopt open jdk and it came with nashorn. Works fine for me. – matt May 23 '19 at 09:56
  • Even works with java 11 out of the box, though there isn't a nashorn.jar isn't in the jdk. – matt May 23 '19 at 10:00
  • Thanks. That's quite unexpected for me! but good news :) – Houtman May 23 '19 at 11:11
  • Rhino engine is available as maven dependency (https://mvnrepository.com/artifact/org.mozilla/rhino-engine). Then it can be used by replacing the "nashorn" engine name with "rhino": `ScriptEngine engine = manager.getEngineByName("rhino");` – morbac Aug 30 '22 at 08:21

2 Answers2

1

I had exactly the same problem and actually manged to found the lost https://java.net/projects/Scripting project.

Here is a GitHub mirror: https://github.com/scijava/javax-scripting. The comment says that this is the final state of that repo, not sure if this is true.

That repo also has a few clones. I found one particularly useful, as it has JDK8 compatible JSR223 implementation for Rhino: https://github.com/zeroboo/java-scripting-rhino-jdk8.

While above are very handy if you need provide backward compatibility with Rhino, for a new project I would rather use GrallVM or Nashorn (note: already deprecated). JSR223 bindings are available for both out of the box: graal.js, nashorn.

tporeba
  • 867
  • 10
  • 23
0

Thanks for the comments. That's good news, that AdoptOpenJDK 8 comes with 'Oracle Nashorn' ! :)

c:/> Java -version
openjdk version "1.8.0_192"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_192-b12)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.192-b12, mixed mode

My test app shows a listing of the available JSR-223 engines: Available script engines:

-------------------------------------------
Language: ECMAScript
Engine:   Oracle Nashorn
Names:    nashorn,Nashorn,js,JS,JavaScript,javascript,ECMAScript,ecmascript
-------------------------------------------

Instantiating it i see:

Name: Oracle Nashorn (version: 1.8.0_192)
Houtman
  • 2,819
  • 2
  • 24
  • 34