Compile failed; see the compiler error output for details

 

出現 Compile failed; see the compiler error output for details錯誤,請大家幫忙解決!!!


public class CopyOfComplierToClass2 {
 
 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;
 }

public static void main(String[] args) {

 

CopyOfComplierToClass2   cct = new CopyOfComplierToClass2 ();

 

System.out.println(cct.sourceConvertClass() );

 

}

 

}

 

 

發佈了41 篇原創文章 · 獲贊 4 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章