rhino

JVM missing Rhino

佐手、 提交于 2019-12-01 06:45:00
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"); 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. The JavaScript Engine is only included in the Sun/Oracle JDK. If you use some other Java implementation like IBM J9 or

JVM missing Rhino

为君一笑 提交于 2019-12-01 05:14:02
问题 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"); 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. 回答1: The JavaScript

How to correctly execute lessc-rhino-1.6.3.js from command line

折月煮酒 提交于 2019-12-01 05:01:00
I'm trying "latest and greatest" LESS version and it seems it does not work in rhino command-line version. I've done following Took latest rhino from here https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip Took latest less-rhino-1.6.3.js from here https://github.com/less/less.js/tree/master/dist Running following from command line java -jar js.jar less-rhino-1.6.3.js text.less text.css or java -jar js.jar less-rhino-1.6.3.js lessc-rhino-1.6.3.js text.less text.css The result is - "silently nothing". When trying to run 'previous latest version' - it runs OK without problems java -jar js

How to correctly execute lessc-rhino-1.6.3.js from command line

与世无争的帅哥 提交于 2019-12-01 02:12:16
问题 I'm trying "latest and greatest" LESS version and it seems it does not work in rhino command-line version. I've done following Took latest rhino from here https://github.com/downloads/mozilla/rhino/rhino1_7R4.zip Took latest less-rhino-1.6.3.js from here https://github.com/less/less.js/tree/master/dist Running following from command line java -jar js.jar less-rhino-1.6.3.js text.less text.css or java -jar js.jar less-rhino-1.6.3.js lessc-rhino-1.6.3.js text.less text.css The result is -

Trying to use Rhino, getEngineByName(“JavaScript”) returns null in OpenJDK 7

做~自己de王妃 提交于 2019-11-30 16:39:55
问题 When I run the following piece of code, the engine variable is set to null when I'm using OpenJDK 7 ( java-7-openjdk-i386 ). import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class TestRhino { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); try { System.out

Clone Entire JavaScript ScriptEngine

只谈情不闲聊 提交于 2019-11-30 14:37:30
I need to somehow deep clone the entire set of bindings of my ScriptEngine object. What I have tried I have tried so far the Cloner library to clone the entire Bindings structure. This would be great if it worked because it would have ensured a precise copy, including private variables. But this leads to jvm heap corruption (the jvm just crashes with exit code -1073740940). Sometimes it doesn't crash but weird things happen, like the System.out.println() stops working as it should... I have also looked into cloning the objects using js code inside the ScriptEngine, so that I can get those as

Java 7 + Rhino 1.7R3 support for CommonJS modules?

為{幸葍}努か 提交于 2019-11-30 12:58:13
问题 I need help getting CommonJS working on Java 7 and Rhino 1.7R3. Rhino 1.7R3 supports CommonJS modules: https://developer.mozilla.org/En/New_in_Rhino_1.7R3 And Java 7 comes bundled with Rhino 1.7R3. Unfortunately, Java 7's Rhino is a modified version, and it does not include the org.mozilla.javascript.commonjs package: http://jdk7.java.net/rhino/README.TXT I would like to use Rhino 1.7R3's support for CommonJS through the javax.script API as follows: ScriptEngineManager mgr = new

如何在另一个JavaScript文件中包含一个JavaScript文件?

百般思念 提交于 2019-11-30 11:40:20
JavaScript中是否有类似于CSS中 @import 的内容,可让您在另一个JavaScript文件中包含一个JavaScript文件? #1楼 而不是在运行时添加,而是使用脚本在上传之前进行串联。 我使用 链轮 (我不知道是否还有其他 链轮 )。 您将JavaScript代码构建在单独的文件中,并包含由Sprockets引擎处理的注释(包括)。 对于开发,您可以依次包含文件,然后在生产中将它们合并... 也可以看看: Sprockets简介:JavaScript依赖关系管理和串联 #2楼 如果有人在寻找更高级的东西,请尝试 RequireJS 。 您将获得更多好处,例如依赖管理,更好的并发性,并避免重复(也就是说,多次检索脚本)。 您可以在“模块”中编写JavaScript文件,然后在其他脚本中将它们作为依赖项引用。 或者,您可以将RequireJS用作简单的“获取此脚本”解决方案。 例: 将依赖项定义为模块: some-dependency.js define(['lib/dependency1', 'lib/dependency2'], function (d1, d2) { //Your actual script goes here. //The dependent scripts will be fetched if necessary. return

ScriptEngine how to pass a String that represent JSON?

橙三吉。 提交于 2019-11-30 10:04:32
问题 I was trying to pass a String object that represents a JSON string from java to javascript function using ScriptEngine in jdk 1.6. My code works in JSFIDDLE http://jsfiddle.net/hn4yk/13/ but when I try to load it with the ScriptEngine it doesn't work and throws an exception sun.org.mozilla.javascript.internal.EcmaError: TypeError: Cannot read property "resultList" from undefined (#1164) I tested that the variable is passed correctly but the eval or the JSON.parse method doesn't work! I tried

How do I call a method of a Java instance from JavaScript?

点点圈 提交于 2019-11-30 09:13:42
I'm using the Mozilla Rhino JavaScript emulator. It allows me to add Java methods to a context and then call them as if they were JavaScript functions. But I can't get it to work except when I use a static method. The problem is this part of the documentation: If the method is not static, the Java 'this' value will correspond to the JavaScript 'this' value. Any attempt to call the function with a 'this' value that is not of the right Java type will result in an error. Apparently, my Java "this" value doesn't correspond with the one in JavaScript and I have no idea how to make them correspond.