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

调用 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 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用