admin管理员组文章数量:1391969
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
engine is null??? Also i try to iterate through the scriptEnginefactories it's zero...
i have js-1.7R1.jar on my classpath...can anyone tell me what i need to do else to register the javascript engine( I found Rhino which is js-1.7r.jar)
Thanks.
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
engine is null??? Also i try to iterate through the scriptEnginefactories it's zero...
i have js-1.7R1.jar on my classpath...can anyone tell me what i need to do else to register the javascript engine( I found Rhino which is js-1.7r.jar)
Thanks.
Share Improve this question asked Oct 5, 2012 at 19:53 Jeryl CookJeryl Cook 1,03819 silver badges42 bronze badges 4- How are you running the class? Through an IDE? If so, is its piler-level set to Java 1.6 or higher? – Bart Kiers Commented Oct 5, 2012 at 19:58
- Eclipse uses its own piler, but uses the system's JRE: you sure your JRE is 1.6+? Do other 1.6 features work? (annotations) – Bart Kiers Commented Oct 5, 2012 at 20:39
- @BartKiers Thanks! your ments help point me in right direction..in my IDE i had to remove my JRE(it was 1.5) and add it back as 1.6....i recently changed to 1.6 but did not fix that...... thanks , i was stuck for a good while :/ – Jeryl Cook Commented Oct 5, 2012 at 20:48
- @Jeryl Cook Can you make that solution official and answer your own question then so that your question can help others. – Kyle Bridenstine Commented Jul 7, 2014 at 0:57
3 Answers
Reset to default 3"Eclipse uses its own piler, but uses the system's JRE..." - Bart Kiers
Make sure the JRE is 1.6 or higher. Based on the ments, Jeryl Cook had eclipse set to JRE 1.5. He removed this from inside eclipse and added JRE 1.6 which worked and solved his problem.
I had the same problem with JDK 11. Using JDK 8 solved it.
Make sure you have
sun.mozilla.javascript.internal, .sun.script.javascript;
packages in your classpath.
What you are trying to run is fork version of Rhino within Java SE (Java Scripting Api). It looks like your Java doesn't have it (check above packages).
I believe js-1.7R1.jar is original Rhino implementation from mozilla - you can try to run it directly link, not via Java Scripting API.
本文标签: javaScriptEngine is Null for getEngineByName(quotJavaScriptquot)Stack Overflow
版权声明:本文标题:java - ScriptEngine is Null for getEngineByName("JavaScript")? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744721806a2621737.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论