Example #1
0
 private void addClassPathToScriptEngine(File jarFile) throws ConfigurationException {
   try {
     StringBuilder cmd = new StringBuilder(addClassPathCmd);
     int tagStartPos = cmd.indexOf(parameterTag);
     int tageEndPos = tagStartPos + parameterTag.length();
     cmd.replace(tagStartPos, tageEndPos, jarFile.getAbsolutePath().replace("\\", "/"));
     // System.out.println("cmd " + cmd.toString());
     engine.eval("add-classpath", 1, 1, cmd.toString()); // $NON-NLS-1$
   } catch (Exception ex) {
     String msg = String.format("Failed to load class path %s", jarFile.getName()); // $NON-NLS-1$
     System.err.println(msg + " " + ex);
     throw new ConfigurationException(msg, ex);
   }
 }
Example #2
0
 /**
  * Imports a package into the script engine
  *
  * @param pkgName the name of the package
  * @throws ConfigurationException if the package cannot be imported
  */
 private void importPkgToScriptEngine(String pkgName) throws ConfigurationException {
   try {
     StringBuilder cmd = new StringBuilder(importPackageCmd);
     int tagStartPos = cmd.indexOf(parameterTag);
     int tageEndPos = tagStartPos + parameterTag.length();
     cmd.replace(tagStartPos, tageEndPos, pkgName);
     // System.out.println("cmd " + cmd.toString());
     engine.eval("load-packages", 1, 1, cmd.toString()); // $NON-NLS-1$
   } catch (Exception ex) {
     String msg = String.format("Failed to import package %s", pkgName); // $NON-NLS-1$
     System.err.println(msg + " " + ex);
     throw new ConfigurationException(msg, ex);
   }
 }