Skip to content
Language-independent scripting environment
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

JScriptBox: Make your scripting API language-independent

Maven artifact Latest version Javadoc License Apache

Changelog Travis CI Live chat

When exposing a scripting API, you provide some variables and functions to the script, run the script, then look at which outputs were set and/or functions were called. JScriptBox provides a mechanism for exposing a Java API to a scripting language in a way which is independent of the script language. This means that if you write your code using JScriptBox, script authors can use any language supported by JSR-223, such as JavaScript, Ruby, Python, Scheme, etc.

At present, only JavaScript is being used in the wild (in the FreshMark project), but PR's which enhance support for other languages are welcome.


private int square(int x) {
	return x * x;

public void example() throws ScriptException {
	TypedScriptEngine engine = JScriptBox.create()
	int squareOfX = engine.eval("square(x)", Integer.class);
	Assert.assertEquals(81, squareOfX);

In the code above, we provide a square function and an x variable. We then build a Nashorn Javascript engine, but we could have passed any other language too. To add a new language, just implement Language (the existing Nashorn can be a helpful starting point).


You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.