List of usage examples for javax.script ScriptException ScriptException
public ScriptException(Exception e)
ScriptException
wrapping an Exception
thrown by an underlying interpreter. From source file:ste.xtest.js.BugFreeJavaScript.java
private void loadResourceScripts(final Context cx, final String[] scripts) throws ScriptException { InputStream is = null;//from w w w. j a v a 2 s.c om try { for (String script : scripts) { is = BugFreeJavaScript.class.getResourceAsStream(script); if (is == null) { throw new FileNotFoundException(script + " not found in classpath"); } cx.evaluateReader(scope, new InputStreamReader(is), script, 1, null); is.close(); is = null; } } catch (Exception x) { throw new ScriptException("Error initializing the javascript engine: " + x.getMessage()); } finally { Context.exit(); if (is != null) { try { is.close(); } catch (Exception x) { } } ; } }