private Compiler(URLClassLoader parent) {
    // If not running on JDK, compiler will be null
    if (compiler == null) {
      throw new Error("Compiler not available.  This may happen if "
          + "running on JRE instead of JDK.  Please use a full JDK 1.6."
          + "javax.tools.ToolProvider.getSystemJavaCompiler() returned null.");
    }
    log.debug("Instantiating new compiler " + parent);
    fileManager = new MemoryOutputJavaFileManager(compiler.getStandardFileManager(null, null, null));
    loader = new JavaFileManagerClassLoader(fileManager, parent);

    // create a classpath for the compiler
    StringBuilder b = new StringBuilder();
    URL[] cp = parent.getURLs();
    for (int i = 0; i < cp.length; i++) {
      b.append(File.pathSeparatorChar);
      b.append(cp[i].getFile());
    }
    /*
     * This is necessary to add all jars of an app when running inside a
     * container
     */
    try {
      URL[] cl = ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
      for (URL url : cl) {
        b.append(File.pathSeparatorChar).append(url.getFile());
      }
    } catch (ClassCastException e) {
      log.error("Context class loader is not a URLClassLoader");
    }

    // set compiler's classpath to be same as the runtime's
    compilerOptions.addAll(Arrays.asList("-cp", System.getProperty("java.class.path") + b.toString()));
  }