代码和报错信息如下
String filePath = "D:\\bossproject\\nontax-industry-standard-police\\nontax-industry-standard-police-service\\src\\main\\java\\com\\bosssoft\\nontax\\industry\\standard\\police\\service\\AgenBusTypeService.java";
String targetPath = "D:\\deskTop\\新建文件夹\\";
File targetPathFloder = new File(targetPath);
if(!targetPathFloder.exists()){
targetPathFloder.mkdirs();
}
File javaFile = new File(filePath);
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
int result = -1 ;
result = javaCompiler.run(null,null,null,"-d",targetPath,javaFile.toPath().toString());