Campbell Ritchie wrote:So it works without the constructor call from the command line and not from Eclipse? How strange.
Are you using the same version of Java® for both? Get the version from the command line with java -version and for Eclipse from Project→Properties.
Yes, I am using the same version of java at both the places. I did not say without constructor but what i meant was in command line I used the constructor without argument and through eclipser I just passed the argument as 'null' to the constructor.
command line i used : ScriptEngine engine = new ScriptEngineManager().getEngineByName("nashorn");
Eclipse : ScriptEngine engine = new ScriptEngineManager(
null).getEngineByName("nashorn");