To use DynJS, the first thing you'll want to do is download the DynJS binary.

Download Now!

Download this file and unzip it. This will create a ./bin/dynjs

Command Line

DynJS comes with a binary that you can use to execute Javascript files on the command line.

$ ./bin/dynjs --help
Usage: dynjs [--console |--debug | --help | --version |FILE]
Starts the dynjs console or executes FILENAME depending the parameters

 FILE      : File to be executed by dynjs
 --console : Opens a REPL console to test small expressions.
 --debug   : Run REPL in debug mode.
 --help    : Shows current screen. Running without parameters also shows this.
 --version : Shows current dynjs version.


DynJS can be embedded into an existing Java application to provide JavaScript scripting abilities from your Java projects. First, you'll need to add the dependency to your build. In maven:


You can provide the embedded runtime with strings or file paths to execute JavaScript.

import org.dynjs.Config;
import org.dynjs.exception.ThrowException;
import org.dynjs.runtime.*;

public class ScriptRunner {
  DynJS dynjs;
  Config config;

  public ScriptRunner() {
    config = new Config();
    dynjs  = new DynJS(config);

  public Object runScript(String fileName) {
    Runner runner = dynjs.newRunner();
    return runner.withSource(new File(fileName)).execute();

  public Object eval(String code) {
    return dynjs.evaluate(code);