Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在使用JavaCompiler接口时指定选项_Java - Fatal编程技术网

如何在使用JavaCompiler接口时指定选项

如何在使用JavaCompiler接口时指定选项,java,Java,这不起作用,如何将classpath选项传递给JavaCompiler实例?您需要在参数前面加上“-”,即-cp或-classpath,就像使用命令行javac一样。另见 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); compiler.run(null, null, null, "cp", System.getProperties().getProperty("java.class.path"), s

这不起作用,如何将classpath选项传递给JavaCompiler实例?

您需要在参数前面加上“-”,即-cp或-classpath,就像使用命令行javac一样。另见

 JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        compiler.run(null, null, null, "cp", System.getProperties().getProperty("java.class.path"), sourceFile.getPath());