Java's ScriptEngine system allows you to run/evaluate statements written in other programming languages like Javascript/ECMAScript, Python/Jython, and Tcl/Jacl.
Questions tagged [scriptengine]
227 questions
5
votes
1 answer
How to do you get output from Javascript into Java using ScriptEngine
With this simple piece of applescript I can list the names of all songs within iTunes
tell application "iTunes"
set mainLibrary to library playlist 1
repeat with nexttrack in (get every track of mainLibrary)
try
name of…

Paul Taylor
- 13,411
- 42
- 184
- 351
4
votes
1 answer
Java returns cannont invoke ScriptEngine error
I am running Java's ScriptEngine class to run to some code. I use IntelliJ with maven dependencies when I run the code it says
Cannot invoke "javax.script.ScriptEngine.eval(String)" because "this.engine" is null
at…

abhishekmohan20xx
- 43
- 1
- 5
4
votes
1 answer
Java: embedding script engines in an application: Is the JSR 223 (ScriptEngine) still a good solution?
I want to use one or many script languages in my Java application.
From JRuby website I found that there are 3 ways:
Using Java 6 (using JSR 223: Scripting)
Embedding with Bean Scripting Framework (BSF)
Directly calling $YOUR_SCRIPTING_ENGINE$…

Guillaume
- 5,488
- 11
- 47
- 83
4
votes
2 answers
How to call function or module using Scala ScriptEngine
How to call function or module using ScriptEngine.
here is my sample code , which is compiling fine , but at runtime its throwing exception scalaVersion := "2.12.4" and sbt.version = 0.13.16, java is jdk1.8.0_131
import java.io.FileReader
import…

Jagan Arikuti
- 365
- 1
- 2
- 11
4
votes
1 answer
JVM missing Rhino
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…

Andrei M. Eichler
- 121
- 2
- 7
4
votes
1 answer
Redirecting Jruby ScriptEngine output to a StringWriter
I recently encountered a strange problem when trying to redirect the ScriptEngine output for my ruby session. It seems that no matter what Ipass in to my ScriptEngine, it always prints to stdout and stderr. I found this post, but it says it's…

voodoogiant
- 2,118
- 6
- 29
- 49
4
votes
1 answer
How can I reuse ScriptContext (or otherwise improve performance)?
I have a homebrew ETL solution. The transformation layer is defined in a configuration file in JavaScript scriptlets, interpreted by Java's Nashorn engine.
I am encountering performance issues. Perhaps there is nothing that can be done, but I hope…

Aaron
- 414
- 4
- 16
4
votes
1 answer
R Script not able to read .Rda file when executed from Java
I'm new to Rscript so please bear with me, I need to execute a R script (written by another developer) from java and for that I'm using Renjin. The R script file and other required files are on classpath i.e. under resources folder.
To achieve this…

Akhil
- 1,184
- 1
- 18
- 42
4
votes
0 answers
ScriptEngineManager: How to make a http request from JavaScript Engine
I'm, using javax.script.ScriptEngineManager, in which, im using the JS Script Engine, like this.
ScriptEngineManager manager = new ScriptEngineManager();
ScriptEngine engine = manager.getEngineByName("js");
engine.eval(str);//str contains JS code as…

anij
- 1,322
- 5
- 23
- 39
4
votes
1 answer
Nashorn JavaScript Invocable.getInterface fails across classloaders in web app
I need to invoke (with Nashorn) from Java code a function defined in JavaScript and to pass there some parameters. Instead of using Invocable.invokeFunction("Foo", arg1, arg2), I was going to define an interface, then request Invocable to produce…

Maksim Gumerov
- 642
- 8
- 23
4
votes
1 answer
Java Scripting API -- Property from JavaScript object is always null
Below is the code I am running in my Java compiler:
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
engine.put("person", "{name: 'Bob', favoriteColor:…

kshah
- 1,667
- 2
- 16
- 24
4
votes
1 answer
Roslyn, passing values through hostObject
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…

Zoriana
- 43
- 4
4
votes
1 answer
How can I restrict access to members in an assembly from Roslyn script engine?
I am experimenting with the Roslyn script engine. Using the following code, I set up my script engine.
var csharpEngine = new ScriptEngine();
csharpEngine.AddReference("System");
csharpEngine.AddReference(this.GetType().Assembly.Location); …

Nate
- 5,237
- 7
- 42
- 52
4
votes
2 answers
Roslyn VisualBasic.ScriptEngine doesnt recognize hostObject written on C#
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…

Bogdan_Ch
- 3,328
- 4
- 23
- 39
3
votes
0 answers
Run Python with imports via java ScriptEngineManager
Similar question have been asked here an year ago but no answer yet.
Im running a Python script via Java and I'm getting
ImportError: No module named numpy in