JVM缺少Rhino [英] JVM missing Rhino

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

问题描述

我有一个使用ScriptEngine处理一些javascript的项目,并且在我的机器上运行良好,但是当我将项目的jar发送到服务器时,我发现服务器的JVM没有内置Rhino,当代码调用

I have a project that uses the ScriptEngine to process some javascript, and worked well on my machine, but when i send the projects's jar to the server, i had discovered that the server's JVM doesn't have Rhino built-in, returning null when the code calls a

new ScriptEngineManager().getEngineByName("javascript");

我去了rhino的下载页面,获取了最新版本,并从中提取了js.jar,在项目中添加了jar,但是仍然有同样的问题.

I went to the rhino's download page, get the most recent version, and extracted the js.jar from it, added the jar on the project, but still have the same problem.

推荐答案

JavaScript引擎仅包含在Sun/Oracle JDK中.如果您使用其他Java实现,例如IBM J9或Oracle JRockit(很有可能在服务器上),或者如果您不使用Sun/Oracle JDK,而是使用Sun/Oracle JRE(甚至可能在服务器上),那么您可以没有JavaScript引擎.

The JavaScript Engine is only included in the Sun/Oracle JDK. If you use some other Java implementation like IBM J9 or Oracle JRockit (quite likely on a server), or if you don't use the Sun/Oracle JDK but the Sun/Oracle JRE (even more likely on a server), then you don't get the JavaScript engine.

您需要使用Sun的完整JDK.

You need to use Sun's full JDK.

还请注意,JDK6附带的JavaScript引擎不是Rhino,而是经过几年淘汰的Rhino的简化版本.特别是缺少了编译器,这意味着性能可能会降低.

Note also that the JavaScript engine shipped with JDK6 is not Rhino, it's a stripped-down lobotomized version of a several year old obsolote release of Rhino. In particular, it is missing the compiler, which means that performance will probably suck.

还要注意,Rhino和JDK6 JavaScript引擎之间的API不一定兼容,即使您设法找到它所基于的Rhino的过时发行版,也是如此.因此,如果要在部署中使用Rhino,最好在开发中也使用它.

Also note that the API is not necessarily compatible between Rhino and the JDK6 JavaScript engine, even if you manage to find that obsolete release of Rhino that it is based on. So, if you want to use Rhino in deployment, you'd better use it in development, too.

最后但并非最不重要的一点:仅仅因为您在Eclipse项目文件中进行了某些输入,并不意味着服务器的类路径将发生神奇的变化.您需要确保正确设置了所有类路径.我对FreeBSD没有任何经验,但是我很确定软件包管理系统(在这种情况下为FreeBSD端口)在port install rhino之后将至少部分地解决该问题.

And last but not least: just because you make some entry in your Eclipse project file, doesn't mean that your server's classpath is going to magically change. You need to make sure that all your classpaths are properly set up. I don't have any eperience with FreeBSD, but I'm pretty sure that the package management system (FreeBSD ports in this case) is going to at least partially take care of that after a port install rhino.

这篇关于JVM缺少Rhino的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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