Eclipse提供了很好的工具:
1、實時運算薄頁面(java scrapbook page)具體的說就是一小段代碼,比如一個for循環,就可以在里面執行,無須寫出main函數等。
操作如下:new->other->java->java run/debug->scrapbook page
創建頁面后,輸入代碼:
for (int i = 0; i < 10; i++) {
System.out.println(Integer.toString(i));
}
選擇代碼,右鍵excute即可看到結果。。很方便。。。。。
2、程序代碼產生模板
window->prefrences->java->editor->Templates
添加:name:Sys
context:java
Description:shortcut for System.out.println
pattern:System.out.println(${cursor});
確定后,在程序中輸入s或Sys時再按alt+/會提示語句。。。接著按enter鍵吧。。。
3、產生 getter 與 setter Java 編輯器可以為編譯單元內的類型字段,產生存取元(accessors,也就是getter和setter的method)。 I. 「Source」→「Generate Getter and Setter...」 (或是在Java編輯器按右鍵,「Source」→「Generate Getter and Setter...」)
挑選哪些需要建立getter和setter的method ;
選擇method要建立的地方 ;
排序的方式;
選擇Access modifier ;
選擇是否需要建立批注;
按OK;
4、建立新的 JAR 檔案 如果要在工作臺中建立新 JAR 檔,請執行下列動作: I. 在「Package Explorer」中,可以選擇性地預選一或多個要匯出的 Java 元素。(在步驟IV中,這些會在JAR Package Specification精靈頁面中自動選出。) II. 從快速菜單或從菜單列的File菜單,選取Export。 III. 選取JAR file,然后按一下Next。
IV. 在JAR Package Specification頁面的Select the resources to export字段中,選取要匯出的資源。 V. 選取適當的勾選框,以指出想Export generated class files and resourcess或Export java source files and resources。附注:這兩種情況皆會匯出所選的資源。 VI. 在Select the export destination字段中,輸入或按一下Browse以選取 JAR 文件的位置。 VII. 選取或清除Compress the contents of the JAR file勾選框。 VIII. 選取或清除Overwrite existing files without warning勾選框。如果清除這個勾選框,則會提示確認是否要更換每一個將被改寫的檔案。 IX. 附注:在撰寫 JAR 檔、JAR 說明與 Manifest 檔時,會套用改寫選項。 X. 有兩項選擇: ?? 按一下Finish來立即建立 JAR 檔。 ?? 按一下Next,使用「JAR 套裝選項」頁面,以設定進階選項,建立 JAR 說明,或變更預設 manifest。
posted on 2007-12-18 15:53
仰望者 閱讀(179)
評論(0) 編輯 收藏