public static void main(String[] args) throws Exception {
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
//        StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
        JavaSourceFromString javaSourceFromString = new JavaSourceFromString(
                "CalculatorTest",
                "public class CalculatorTest {"
                        + " public int multiply(int multiplicand, int multiplier) {"
                        + " System.out.println(multiplicand);"
                        + " System.out.println(multiplier);"
                        + " return multiplicand * multiplier;" + " }" + "}");

        JavaCompiler.CompilationTask task = compiler.getTask(null, null,
                null, Arrays.asList("-d","f:/"),//class文件输出路径
                null, Arrays.asList(javaSourceFromString));
        Boolean result = task.call();
        System.out.println(result);
        if (result) {
            URL[] urls=new URL[]{new URL("file:/f:/")};
            URLClassLoader classLoader=new URLClassLoader(urls);
            Class clazz = classLoader.loadClass("CalculatorTest");
            Object instance = clazz.newInstance();
            Method m = clazz.getMethod("multiply", new Class[] { int.class,
                    int.class });
            Object[] o = new Object[] { 3, 2 };
            System.out.println(m.invoke(instance, o));
        }
    }