zhuguanghe19870614 2011-03-09 14:04
浏览 1996
已采纳

调用 Ant api 出现Compile failed; see the compiler error output for details异常

[b][color=red][color=red][color=red]该方法是把d:/generator-output/hibernate/code/这个文件夹下的多个.java编译为.class文件[/color][/color][/color][/b]

但是出现Compile failed; see the compiler error output for details异常,希望大家帮忙解决,谢了

public boolean sourceConvertClass() {
boolean flag = false;
File f = new File("d:/generator-output/hibernate/code/");

    // 找到所有的文件
    File[] files = f.listFiles();
    Javac compiler = new Javac();
    File destFile = null;
    for (File file : files) {
        // 找出不含.java文件
        if (file.getName().contains(".java")) {
            compiler.setProject(new Project());
            // 编译后的.class文件存放的路径
            destFile = new File("d:/generator-output/hibernate/code/");
            destFile.mkdirs();
            // 要编译的源文件目录
            Path srcPath = new Path(compiler.getProject(),
                    "d:/generator-output/hibernate/code/");
            compiler.setFork(true);
            compiler.setSrcdir(srcPath);
            compiler.setDestdir(destFile);
            try {
                compiler.execute();
                flag = true;
            } catch (BuildException e) {

                //System.out.println("编译.class文件出现错误");
            }
        }

    }

    return flag;
}
  • 写回答

2条回答 默认 最新

  • liuchina_it 2011-03-09 14:14
    关注

    我记得也遇到过这样的情况。我当初没有编译。但当我编译了,就没有错 了。我也没有管了。你看看是否ToMact给的内存够吗?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵