bedatadriven / renjin-docs

Documentation for Renjin, the R interpreter for the JVM
7 stars 4 forks source link

Invoke RenjinScriptEngineFactory directly #9

Closed akbertram closed 7 years ago

akbertram commented 8 years ago

The docs currently tell users to create a ScriptEngine instance this way:

    ScriptEngineManager manager = new ScriptEngineManager();
    // create a Renjin engine:
    ScriptEngine engine = manager.getEngineByName("Renjin");
    // check if the engine has loaded correctly:
    if(engine == null) {
        throw new RuntimeException("Renjin Script Engine not found on the classpath.");
    }

Unfortunately, in the event of an error, the javax.scripting API will throw away all information about the error and leave us only with a null.

In place of this, the user can invoke RenjinScriptEngineFactory directly:

RenjinScriptEngine engine = new RenjinScriptEngineFactory().getScriptEngine();

This will preserve the stack trace and details about any problem that occurs.

We can still mention the getEngineByName("Renjin") method for those who are working with multiple script engines, for example, but for most users, instantiating it directly will be more helpful.

akbertram commented 7 years ago

Fixed by 4ebd91be604df9cf04f4d76a64db6927d3a22c52