Nashorn在Java 7下 [英] Nashorn under Java 7

查看:102
本文介绍了Nashorn在Java 7下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试让Oracle的Nashorn在Java 7下运行。

I'm trying to get Oracle's Nashorn running under Java 7.

我克隆了repo并编译了源代码。我需要做的就是编译:

I've cloned the repo and compiled the source. All I had to do to get it to compile was:


  • 将jdk.internal.org.objectweb.asm。*更改为org.objectweb .asm。*

  • 更改一行有Long.hashCode()静态的行。

一切似乎都很开心,Java 7将Nashorn视为脚本引擎;但是当我尝试获取一个实例时:

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();

我得到例外:


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)

jdk.nashorn.api.scripting.NashornScriptEngine。(NashornScriptEngine.java:78)
at
jdk.nashorn.api.scripting.NashornScriptEngineFacto ry.getScriptEngine(NashornScriptEngineFactory.java:139)

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在我的类路径中。 Nashorn可能会使用不同的类加载器吗?

jdk.nashorn.internal.objects.Global is in my class path. Does Nashorn use a different class loader maybe?

推荐答案

我试过让它在7之前工作并遇到同样的错误就像你一样。我认为这与Nashorn在Java 8中使用一些新功能这一事实有关。

I tried getting it to work under 7 previously and was met by the same error as you have. I think it has to do with the fact that Nashorn makes use of some new features in Java 8.

有一个 backport for bitbucket上的JDK 7;我写了一篇博文,详细介绍了如何在我的作品博客上使用它这里。您还可以查看此堆栈溢出问题以获取更多信息。

There is a backport of Nashorn for JDK 7 on bitbucket; I wrote a blog post detailing how to use it on my works blog here. You can also look at this stack overflow question for more information.

该bitbucket项目在一段时间内没有更新,我建议你如果你想和Nashorn一起玩,可以使用 Java 8 的预览。

That bitbucket project hasn't been updated in some time, I'd recommend that you use the preview of Java 8 if you want to play with Nashorn.

这篇关于Nashorn在Java 7下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆