scriptengine

JavaScript ScriptEngine isn't working within Google App Engine for Java (GAE/J)

喜夏-厌秋 提交于 2019-12-25 02:53:52
问题 I am having an issue where I always get a 0 value returned when I try to use the ScriptEngine eval. By using Logger, I was able to determine that there are NullPointerExceptions being generated. After further inspection, it appears that GAE doesn't always return a valid script engine (if ever), because it throws an exception when you try to use it. My code looks like: public double myEval(String JsFormulaStr ) { double solutionValue = 0; ScriptEngineManager mgr = new ScriptEngineManager();

Java execute Embedded Python with parameters

让人想犯罪 __ 提交于 2019-12-24 15:33:12
问题 I want to execute Embedded python in Java. Python code #!/usr/bin/python import sys print 'Number of arguments:', len(sys.argv), 'arguments.' print 'Argument List:', str(sys.argv) Java Code StringWriter writer = new StringWriter(); // ouput will be stored here ScriptEngineManager manager = new ScriptEngineManager(); ScriptContext context = new SimpleScriptContext(); context.setWriter(writer); // configures output redirection ScriptEngine engine = manager.getEngineByName("python"); engine.eval

Can JavaScript use classes from a jar file (Non Internet Use)

你。 提交于 2019-12-24 03:04:20
问题 I have an API in a jar file but how can I use the classes from the jar in JavaScript? When I try importing them, conf = Packages.abcapi.Config; var cfg = new conf.Config(); It doesn't work. This is not going to be used in a browser or over the internet. UPDATE: I'm extending our API to all JSR-223 Scripting Languages using Java ScriptEngine. Inside the Java application I read a JavaScript File and then execute the file using ScriptEngine. I need for the JavaScript File to use classes from the

Roslyn VisualBasic.ScriptEngine doesnt recognize hostObject written on C#

只谈情不闲聊 提交于 2019-12-22 08:37:56
问题 Our project need ability to have a simple business rules our customers can script in Visual basic. While our main program is written on C# The script which customers want to execut could be like this (I am considering the simpliest possible case) var vbCode = @" If (Row.Code = 12) Then Row.MappedCode = 1 End If"; So I created a RowData class in C# with Code and MappedCode properties namespace ScriptModel { public class RowData { public int Code { get; set; } public int MappedCode { get; set;

How do you invoke a method in a Nashorn CompiledScript?

不想你离开。 提交于 2019-12-17 20:11:59
问题 I have the following code which works: ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); jsEngine.eval("some script"); jsEngine.invokeMethod(jsEngine.eval("foo"), "bar"); but I want to do use a pre-compiled script so I don't have to evaluate the script every time I need to run it, so I'm trying; ScriptEngine jsEngine = ScriptEngineManager.new().getEngineByName("nashorn"); CompiledScript compiledJS = jsEngine.compile("some script"); but then I'm not sure what to do

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

99封情书 提交于 2019-12-17 07:41:52
问题 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? 回答1: 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. 回答2: For the classes javax.script.ScriptEngine, javax.script.ScriptEngineFactory and so on, you can add the jsr223

parse and execute JS by C#

两盒软妹~` 提交于 2019-12-17 02:28:40
问题 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? 回答1: To answer the question title "How to parse and execute

Add numbers with the word “add”

时光毁灭记忆、已成空白 提交于 2019-12-12 00:31:44
问题 I am writing to offer an application in Java right now and instead of using the operator "+", the user of the application can literally use the word "add" to add two numbers together. I'm quite stuck on how to do this because I can't really use a method in order to complete the function considering I'd have to type "add()" rather than just "add". Unless there is a way to execute a method without the parentheses. Would I have to write a completely new class or is there an easier way to do this

PageDown through ScriptEngine incorrectly parsing Markdown

南笙酒味 提交于 2019-12-10 15:23:49
问题 I am trying to use PageDown on the client side as an editor, and on the server side to then parse that Markdown to HTML. It seems to work fine on the client side, but on the server side, tickmarks are only "codifying" the character that follows, not the word that it wraps. So if I do this: test `test` test I expect this, and this is indeed what I get on the client side: test <code>test</code> test But on the server side, I end up getting this instead: test <code>t</code>est<code> </code>test

Roslyn, passing values through hostObject

你离开我真会死。 提交于 2019-12-06 04:13:01
问题 I am trying to send one class through hostObject but apparently it doesn't want to work: using Roslyn.Compilers; using Roslyn.Compilers.CSharp; using Roslyn.Scripting; using Roslyn.Scripting.CSharp; public class ShippingService { public class ShippingDetails//class that I want to send { public decimal total { get; set; } public int quantity { get; set; } public string destination { get; set; } } public static string ShipingCost(decimal total, int quantity, string destination) { var details =