本文介绍了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();

我得到例外:

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.

有一个 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一起玩,可以使用的预览。

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下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 20:28