Some time ago I read about JavaTM Scripting API, but I could not find information about which language-interpreters (excepting JS) Oracle JVM implements. Where can I find a full list? Or does the JVM not interpret anything but JavaScript by default?
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript"); // what else?
I'm guessing you know most of what I'm about to say, but lest someone else stumble upon this who doesn't:
Javascript is included by default, as it was the reference implementation (Rhino). It's not quite right to consider it "embedded" - the implementation just happens to be bundled as a reference implementation for JSR-223. As far as I'm aware, it's no different than any other implementation, except that it happens to exist by default.
However, implementations exist for MANY other languages, aren't JVM/JDK specific (just requiring Java 6 or better) and are fairly trivial to add in an application.
I've used Perl, Groovy, Haskell, Javascript, and Python and a few others (doing some performance testing, related to possibly using it as a solution).
There are a lot of available languages if you want to install them: https://confluence.deri.ie:8443/display/romulus/JSR+223+compliant+scripting+languages
I found answer with @Jesper assistance. javax.script.ScriptEngineManager
has method getEngineFactories()
which returns...
...a list whose elements are instances of all the ScriptEngineFactory classes found by the discovery mechanism.
I wrote this code snippet to get list of supported engines:
ScriptEngineManager factory = new ScriptEngineManager();
for (ScriptEngineFactory sef : factory.getEngineFactories()) {
System.out.println(sef.getEngineName() + " (" + sef.getLanguageName() + ")");
}
Output:
Mozilla Rhino (ECMAScript)
Rhino is an open-source implementation of JavaScript written entirely in Java.
Oracle JDK has only one embedded script-language interpreter - JS interpreter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With