使用eclipse產生jar檔案(jar)
程式裡引用了別的JAR包專案檔夾下建一個META-INF檔案夾裡面建立一個
MANIFEST.MF的檔案內容大至如下
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_06-57 ("Apple Computer, Inc.")
Built-By: hani
Main-Class: com.opensymphony.workflow.designer.Launcher
Class-Path: looks.jar forms.jar syntax.jar jgraph.jar foxtrot.jar osworkflow-2.8.0.jar oscore-2.2.5.jarMain-Class:要啟動並執行類。
Class-path:要引入的包
用eclipse匯出jar檔案裡,選擇
user existing manifest from workspace
manifest file:/項目名/src/META-INF/MANIFEST.MF---------------------------------------------------------------
使用eclipse產生文檔(javadoc)
使用eclipse產生文檔(javadoc)主要有三種方法:
1,在項目列表中按右鍵,選擇Export(匯出),然後在Export(匯出)對話方塊中選擇java下的javadoc,提交到下一步。
在Javadoc Generation對話方塊中有兩個地方要注意的:
javadoc command:應該選擇jdk的bin/javadoc.exe
destination:為產生文檔的儲存路徑,可自由選擇。
按finish(完成)提交即可開始產生文檔。
2,用菜單選擇:File->Export(檔案->匯出),
剩下的步驟和第一種方法是一樣的。
3,選中要產生文檔的項目,然後用菜單選擇,
Project->Generate Javadoc直接進入Javadoc Generation對話方塊,剩餘的步驟就和第一種方法在Javadoc Generation對話方塊開始是一樣的。---------------------------------------------------------------
有時候想把某些.jar檔案當作所有工程的共用部分,比如log4j-1.2.13.jar,怎麼設定才能共用。每次都是通過設定工程--參數--庫 來增加外部jar檔案來實現的,這樣建立一個工程就要設定一次,麻煩。把eclipse 預設的jre包編輯下,加入想預設加入的jar包,然後把這個jre設定為eclipse預設建立工程時使用的jre就可以了。
eclipse>window>preferences>java>installed JREs>編輯預設的jre環境----------------------------------------------------------------
To create a new JAR file in the workbench:
1. In the Package Explorer, you can optionally pre-select one or more Java elements to export. (These will be automaticallyselected in the JAR Package Specification wizard page, described in Step 4.)
2. From the menu bar, select File > Export.
3. Select JAR file, then click Next.
4. In the Jar Package Specification page, select the resources that you want to export in the Select the resources to exportfield.
5. Select the appropriate check box to specify whether you want to Export generated class files and resources or Export Javasource files and resources.Note: Selected resources are exported in both cases.
6. In the Select the export destination field, either type or click Browse to select a location for the JAR file.
7. Select or clear the Compress the contents of the JAR file check box.
8. Select or clear the Overwrite existing files without warning check box. If you clear thischeck box, then you will beprompted to confirm the replacement of each file that will be overwritten.Note: The overwrite option is applied when writingthe JAR file, the JAR description, and the manifest file.
9. You have two options:
Click Finish to create the JAR file immediately.
Click Next to use the JAR Packaging Options page to set advanced options, create a JAR description, or change the defaultmanifest.
提醒:一定要按Next,到最後一步的那個畫面中,有一個項,是選擇入口類,也就是主類。這個一定要設定,否則,打包完後的.jar是不能啟動並執行。