javax.script.ScriptEngine Console extension or library?
<p>With this I have added the console.log functionality to the javax.script.ScriptEngine.</p>

<pre><code>   public class Console {
        public void log(String text){
            System.out.println("console: " + text);
        }
    }

    private static ScriptEngine getJavaScriptEngine(){
    ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");

    Console console = new Console();
    engine.put("console", console);

    return engine;
     }
</code></pre>

<p>As console and alert etc. are not part of the implementation. After a lot of searching I only found here and eleswhere only the same statement but wondering if there is not a library which does this right ?</p>