2015-09-26 34 views
0

我有一個我創建的包,並用ant將它編譯成jar文件。導入編譯爲jar包:錯誤的類文件,類文件包含錯誤的類和包不存在錯誤

的文件結構是這樣的

project folder 
    x_package 
    compiled package_x.jar 
    com 
     name 
     package_x 
      Package files 
    demos 
    src 
     files I'm trying to compile 

我試圖編譯的文件下演示/ src目錄具有依賴於通過增加package_x.jar編譯package_x.jar

我這樣做到classpath中作爲參數傳遞給javac任務

javac任務

<javac destdir = "${build.dir}" source = "${ant.java.version}" target = "${ant.java.version}" 
     debug = "true" deprecation = "false" optimize = "false" failonerror = "true" > 
     <src path = "${source.dir}" /> 
     <classpath refid = "master-classpath"/> 
    </javac> 

主類路徑

<path id = "master-classpath" > 
     <fileset dir = "${classpath.dir}" > 
      <include name = "*.jar" /> 
     </fileset> 
     <pathelement path = "${classpath.dir}" /> 
    </path> 

每當運行ant文件,2個錯誤發生

error: package package_x does not exist 

並且在所述第一參考一個類在包中定義

error: Cannot access class_name 
bad class file C:/(path)/package_x.jar (class_name) 
class file contains wrong class: package_x.class_name 
please remove or make sure it appears in the correct subdirectory of the classpath 
在package_x軟件包中的

每個文件都以

開頭
package package_x; 
/*code*/ 

,並在演示目錄中的文件有

import package_x.*; 
/*code*/ 

任何建議表示讚賞

回答

0

我不知道,如果這是唯一的問題,但在包聲明,你有進口編寫完整的包路徑,如com.name.package_x