scriptengine

Using Rhino instead of ScriptEngine to run Javascript code in Java

拈花ヽ惹草 提交于 2019-12-01 15:39:38
Based on the discussion converting string representation of unknown date-format to Date in java , I want to use the JavaScript Date function in my App-Engine project. However, ScriptEngine does not work on App-Engine. So I need a little help converting to Rhino. Here is the ScriptEngine code I need to convert: ScriptEngineManager scriptEngineManager = new ScriptEngineManager(); ScriptEngine engine = scriptEngineManager.getEngineByName("JavaScript"); String script = "var date = new Date('" + dateInUnknownFormat + "'); var timestamp = date.getTime();"; engine.eval(script); long timestamp = (

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

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

Clone Entire JavaScript ScriptEngine

前提是你 提交于 2019-11-29 20:14:28
问题 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

Use a jar in JavaScript through Java ScriptEngine

倖福魔咒の 提交于 2019-11-29 13:14:05
I need to use classes from a jar file inside JavaScript. I'm using JavaScript through Java ScriptEngine and would like to do something similar to what I did with Jython here, import org.python.core.Py; import org.python.core.PySystemState; ... PySystemState engineSys = new PySystemState(); engineSys.path.append(Py.newString("C:/GMSEC_API/bin/gmsecapi.jar")); Py.setSystemState(engineSys); ScriptEngine engine = new ScriptEngineManager().getEngineByName("python"); When I do this with Jython it works fine and the python files can use the api classes that are inside the jar file. Kyle Bridenstine I

Use a jar in JavaScript through Java ScriptEngine

£可爱£侵袭症+ 提交于 2019-11-28 07:27:15
问题 I need to use classes from a jar file inside JavaScript. I'm using JavaScript through Java ScriptEngine and would like to do something similar to what I did with Jython here, import org.python.core.Py; import org.python.core.PySystemState; ... PySystemState engineSys = new PySystemState(); engineSys.path.append(Py.newString("C:/GMSEC_API/bin/gmsecapi.jar")); Py.setSystemState(engineSys); ScriptEngine engine = new ScriptEngineManager().getEngineByName("python"); When I do this with Jython it

Reference javax.script.ScriptEngine in android or evaluate a javascript expression

别来无恙 提交于 2019-11-27 05:19:41
Is it possible to reference the javax.script.ScriptEngine library when developing an android application? If not is there anyway possible to evaluate a javascript expression in android? javax.script.ScriptEngine is not a default part of android, but you could easily jar up any libraries you need(assuming the size is reasonable, I'm not sure) and include them in your project. For the classes javax.script.ScriptEngine, javax.script.ScriptEngineFactory and so on, you can add the jsr223.jar to your Android project: just copy the .jar file to your libs directory, and add it from Properties->Java

parse and execute JS by C#

旧时模样 提交于 2019-11-26 12:12:14
i have simple crawler which crawl and search page. but now i have problem how to execute and parse js link from that page. Does anyone have any idea how to parse and execute js page? example: some_url is simple to parse with webhtmltoolktit JAVASCRIPT:runmeat(1,7,0,2,7,9) is js link which redirect then to some_url2 page and this page i need to crawl then. but problem is how to execute this javascript in C# to get that some_url2 link? To answer the question title "How to parse and execute JS in C#", here is piece of code that wraps the Windows Script Engines . It supports 32-bit and 64-bit