Questions tagged [javax.script]

A scripting API consists of interfaces and classes that define Java Scripting Engines and provides a framework for their use in Java applications.

The javax.script package available in Java 6+ allows the definition and execution of text based scripts supplied from strings, URLs, Readers or InputStreams. A standard J2SE JVM includes support for JavaScript. Support for additional languages is available either programmatically or through the Java Service Provider mechanism.

Available language support includes:

These implementations are available at the java.net Scripting project website.

58 questions
0
votes
1 answer

How to get the line number of an error when calling Kotlin from Java?

I'm trying to get which line is generating an error when calling a kotlin script from java. The following code gives line number -1. try { String scriptcode = "\n\nthrow Exception()"; ScriptEngineManager factory = new ScriptEngineManager(); …
nevcx
  • 520
  • 6
  • 9
0
votes
1 answer

Redirect stdout of KotlinScriptEngine in javax.script API

I am executing kotlin scripts using javax.script API. I want to capture the output and print the logs later. I am able to do this for nashorn script engine , but the same does not work on KotlinScriptEngine. public void testExampleNashorn()…
Abhinaya P
  • 101
  • 1
  • 9
0
votes
0 answers

How do I call a method from Java's ScriptEngine(javascript) staticly, with type parameters?

I am loading a class from a jarfile at runtime (because the script won't always use that exact jar), so I have a Class object of it. I am also doing that from javax.script.ScriptEngine (javascript). That class has the method public static User…
nickguletskii
  • 292
  • 4
  • 9
0
votes
4 answers

I am unable to evaluate string using eval()

I am trying to make a calculator application.I want to evaluate the contents of a TextView and display it as a toast message. The eval() statement throws an exception for ScriptException as below. "Unhandled exception: javax.script.ScriptException"…
0
votes
1 answer

Evaluating a string holding a logic operation as a Boolean in java

I am trying to evaluate "in1 && in2" to a Boolean as a test, but i hope to be able to evaluate all booleans as stings for my actual project. in1 and in2 are the names of nodes that have a boolean state, i get the actual expression like so, logic =…
James Oswald
  • 470
  • 2
  • 8
  • 21
0
votes
1 answer

Save an SVG image from a website using Java (desktop)

I'm generating a website with JDenticon using this code (test.html): Test