JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
compiler.run(null, null, null, "cp", System.getProperties().getProperty("java.class.path"), sourceFile.getPath());
this not work, how to pass classpath option to JavaCompiler instance ?
You need to precede the argument with ‘-‘ i.e.
-cpor-classpathas if you would use the command line javac. See also javac