Search code examples
javajavascriptnashorn

Nashorn Script Engine is null on Java 8 SE Embedded


I am attempting to bring JavaScript funtionality onto my robotics platform, usijng Java 8's brand new Nashorn engine. Here's the line used to create an instance of the Nashorn script engine:

ScriptEngine nashorn = new ScriptEngineManager().getEngineByName("nashorn");

Running this on my own computer works fine, but on the deployment platform, the resulting nashorn object is null, and whenever it is used of course gives a NullPointerException. After a little debugging, we know that the new ScriptEngineManager() is not null, however the engine returned by .getEngineByName(); is null.

This issue is occuring on the FIRST Robotics roboRIO, running Java 8 SE Embedded.


Solution

  • They are using compact 2 Java profile for creating JRE. You should create Your own JRE which includes nashorn.