Nashorn Standalone 15.3 engine returned is null
Attila Szegedi
szegedia at gmail.com
Tue Jul 13 14:01:34 UTC 2021
I’m honestly not sure. I have this very small test program:
import javax.script.*;
public class X {
public static void main(String[] args) throws ScriptException {
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.eval("function f() { print('Hello, World!'); } f()");
}
}
if I put it in a directory where I checked out Nashorn repo, and run “ant jar” to build the JAR file and run:
java --module-path build/nashorn/dist:build/nashorn/dependencies X.java
It prints "Hello, World!” as expected, so it definitely find the engine under the name “JavaScript". I can also run it with classpath instead of module path:
java -cp build/nashorn/dist/nashorn.jar:build/nashorn/dependencies/asm-7.3.1.jar:build/nashorn/dependencies/asm-util-7.3.1.jar X.java
and that works too. Do you have the dependencies (ASM) too?
Attila.
> On 2021. Jul 13., at 15:33, Andreas Mueller <am at iit.de> wrote:
>
> Hi,
>
> I’ve added Nashorn to Java 15 and it is properly displayed when listing the engines:
>
> 2021-07-13 15:14:30.233/sys$streams/INFORMATION/starting, available Scripting Engines:
> 2021-07-13 15:14:30.246/sys$streams/INFORMATION/name=OpenJDK Nashorn, version=15.3, language name=ECMAScript, language version=ECMA - 262 Edition 5.1, names=[nashorn, Nashorn, js, JS, JavaScript, javascript, ECMAScript, ecmascript]
>
> However, when I get the engine with name “JavaScript” it returns null:
>
> engine = manager.getEngineByName((String) entity.getProperty("script-language").getValue());
> if (engine == null)
> throw new Exception("Engine for script-language '" + entity.getProperty("script-language").getValue() + "' not found!");
>
> 2021-07-13 15:14:30.361/ERROR/Exception occured: java.lang.Exception: Engine for script-language 'JavaScript' not found!
>
> Any ideas what the problem could be?
>
> Thanks,
> Andreas
> --
> Andreas Mueller
> IIT Software GmbH
> http://www.swiftmq.com <http://www.swiftmq.com>
>
>
More information about the nashorn-dev
mailing list