I'm trying to get Oracle's Nashorn running under Java 7.
I've cloned the repo and compiled the source. All I had to do to get it to compile was:
- Change jdk.internal.org.objectweb.asm.* to org.objectweb.asm.*
- Change one line that had Long.hashCode() static.
Everything seems happy, and Java 7 sees Nashorn as a scripting engine; but when I try and get an instance:
NashornScriptEngineFactory factory = new NashornScriptEngineFactory();
ScriptEngine engine = factory.getScriptEngine();
I get the exception:
java.lang.RuntimeException: java.lang.ClassNotFoundException:
jdk.nashorn.internal.objects.Global at
jdk.nashorn.internal.runtime.Context.newGlobalTrusted(Context.java:831)
at jdk.nashorn.internal.runtime.Context.newGlobal(Context.java:636)
at
jdk.nashorn.api.scripting.NashornScriptEngine$2.run(NashornScriptEngine.java:270)
at
jdk.nashorn.api.scripting.NashornScriptEngine$2.run(NashornScriptEngine.java:266)
at java.security.AccessController.doPrivileged(Native Method) at
jdk.nashorn.api.scripting.NashornScriptEngine.createNashornGlobal(NashornScriptEngine.java:266)
at
jdk.nashorn.api.scripting.NashornScriptEngine.(NashornScriptEngine.java:104)
at
jdk.nashorn.api.scripting.NashornScriptEngine.(NashornScriptEngine.java:78)
at
jdk.nashorn.api.scripting.NashornScriptEngineFactory.getScriptEngine(NashornScriptEngineFactory.java:139)
jdk.nashorn.internal.objects.Global is in my class path. Does Nashorn use a different class loader maybe?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…