一、編譯源代碼
1》 編譯整個工程
1. 啓動cmd
2. 進入目錄源代碼目錄:
E:\android\workspace\Thinking_in_Java_Fourth_Edition_Code>
3. 執行ant build
2》 運行整個章節
進入某個章節的目錄,執行ant
3》 運行某個章節中的一個程序: ant 程序名
...\Thinking_in_Java_Fourth_Edition_Code\polymorphism>ant Music
二、 編譯問題解決
1....\Thinking_in_Java_Fourth_Edition_Code\build.xml:59: J2SE5 required
解決辦法:
<condition property="version1.5">
<equals arg1="1.5" arg2="${ant.java.version}"/>
</condition>
修改爲:(由於使用的是1.7)
<condition property="version1.7">
<equals arg1="1.7" arg2="${ant.java.version}"/>
</condition>
<fail message="J2SE5 required" unless="version1.5"/>
修改爲:
<fail message="J2SE7 required" unless="version1.7"/>
2. ...\Thinking_in_Java_Fourth_Edition_Code\net\build.xml:45:
You must install the Javassist library from http://sourceforge.net/projects/jboss/
解決辦法:將javassist-3.12.0.GA.jar拷貝到目錄...\jdk1.7.0_45\jre\lib\ext
3. ...\Thinking_in_Java_Fourth_Edition_Code\xml\build.xml:34: You must install the XOM library from http://www.xom.nu
解決辦法:將xom-1.2.10.jar拷貝到目錄...\jdk1.7.0_45\jre\lib\ext
4. ...\Thinking_in_Java_Fourth_Edition_Code\gui\build.xml:45: You must have javaws.jar in your classpath
解決辦法:設置環境變量CLASSPATH 添加路徑...\jdk1.7.0_45\jre\lib\javaws.jar,重啓cmd
5. ...\Thinking_in_Java_Fourth_Edition_Code\swt\build.xml:45: You must install the SWT library from http://www.eclipse.org
解決辦法:將swt.jar拷貝到目錄....\jdk1.7.0_45\jre\lib\ext
三、 相關代碼以及編譯庫的下面路徑
JAVA編程思想源代碼及其jar庫