[英]JSObject: Download it or available in JRE 1.6?
This is a question from a Java noob. 这是来自Java noob的问题。
I have eclipse open (JRE 1.6), I have copied this code into an eclipse class . 我有eclipse open(JRE 1.6), 我已将此代码复制到eclipse类中 。
The line in question is this: 有问题的一行是这样的:
import netscape.javascript.JSObject;
Eclipse is complaining that the import can not be resolved. Eclipse抱怨导入无法解决。 I read that in the docs that the Java Plug-In comes as standard and contains the above.
我在文档中读到了Java Plug-In作为标准并包含上述内容。 I assumed I don't need any extra JAR files.
我以为我不需要任何额外的JAR文件。 Is this true?
这是真的?
Or do I need to download something to make use of JSObject? 或者我是否需要下载一些东西才能使用JSObject?
Thanks all 谢谢大家
Search for the plugin.jar
normally located in your jre\\lib
folder. 搜索通常位于
jre\\lib
文件夹中的plugin.jar
。 You will need to include that one explicitly in your eclipse project I guess 你需要在你的eclipse项目中明确地包含那个
btw. 顺便说一句。 don't forget to set the
MAYSCRIPT
attribute on your applet tag in order to explicitly enable java-js communication which normally is disabled by default for security reasons 不要忘记在applet标记上设置
MAYSCRIPT
属性,以便显式启用java-js通信,出于安全原因,默认情况下通常会禁用该通信
如果在linux中你找不到jar文件(可能使用openjre)只需将它从Windows安装复制到你的本地linux发行版并像使用任何其他jar文件一样使用它。
Javascript is just one of the ScriptEngines in JDK1.6. Javascript只是JDK1.6中的ScriptEngines之一。
http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/ : http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/ :
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
try {
jsEngine.eval("print('Hello, world!')");
} catch (ScriptException ex) {
ex.printStackTrace();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.