Example usage for jdk.nashorn.internal.runtime Version Version

List of usage examples for jdk.nashorn.internal.runtime Version Version

Introduction

In this page you can find the example usage for jdk.nashorn.internal.runtime Version Version.

Prototype

private Version() 

Source Link

Usage

From source file:com.threecrickets.scripturian.adapter.NashornAdapter.java

License:LGPL

/**
 * Constructor.// w  ww. j a  va2 s . c om
 * 
 * @throws LanguageAdapterException
 *         In case of an initialization error
 */
public NashornAdapter() throws LanguageAdapterException {
    super("Nashorn", Version.version(), "JavaScript", new NashornScriptEngineFactory().getLanguageVersion(),
            Arrays.asList("js", "javascript", "nashorn"), "js", Arrays.asList("javascript", "js", "nashorn"),
            "nashorn");

    try {
        System.setProperty("nashorn.persistent.code.cache", getCacheDir().getCanonicalPath());
    } catch (IOException x) {
        throw new LanguageAdapterException(NashornAdapter.class,
                "Could not access cache directory: " + getCacheDir(), x);
    }

    PrintWriter out = new PrintWriter(new ExecutionContextWriter(), true);
    PrintWriter err = new PrintWriter(new ExecutionContextErrorWriter(), true);

    // See: jdk.nashorn.internal.runtime.ScriptEnvironment
    Options options = new Options("nashorn", err);
    options.set("print.no.newline", true);
    options.set("persistent.code.cache", true);
    ErrorManager errors = new ErrorManager(err);

    context = new Context(options, errors, out, err, getClass().getClassLoader());
}