openfire+elipse的導入配置


中文版:

 

 

2009-01-11 13:33

       Openfire 是由Jive Software 主導開發的一套功能非常強大的開源im 服務器(前身是wildfire),它基於XMPP 協議,完全用java實現,是一款非常優秀的服務器端軟件。


一. 安裝JDK(我使用的是JDK1.6), 不再詳述
二. 安裝 Eclipse 3.3(不再詳述)
三. 安裝Subversive插件
     Subversive是一款不錯的svn插件,具體安裝方法請參看我的另一篇文章《Eclipse中安裝svn插件Subversive 》,鏈接
http://blog.csdn.net/zhenyucheung/archive/2008/03/19/2195518.aspx

四. check out openfire 源碼
   1. 在eclipse中點擊Windows->Open Perspective->Other
   2. 在彈出窗口中點擊SVN Repository Exploring 然後點OK
   3. 在SVN Repositories 點右鍵,選擇 New->Repository Location...
   4. 在彈出的New Repository Location頁面,將
http://svn.igniterealtime.org/svn/repos輸入URL文本框, 點 Finish. 你將會看到頁面出現URL地址.
   5. 展開URL地址
   6. 展開openfire樹形結構
   7. 在trunk上點擊右鍵,選擇Check Out
   剩下的就是等待check out完成了 :)


五. 創建openfire工程
對使用過eclipse的人來說,這一步不用多說,這裏僅列出幾個需要注意的地方.
1. check out完畢後,eclipse會自動創建一個openfire工程,請把它刪除(注意刪除時不要刪除content),否則你將不得不手動配置一些開發環境。
2. 用Create project from existing source新建工程,注意工程名要用openfire。

-----------------

   自己創建工程:

五.創建Java項目,將源代碼導入此項目中。在Eclipse中將此Java文件夾當成源代碼文件夾新建工程。庫都在Build目錄的lib目錄下,將openfire用到的庫都添加到這個新建工程的Referenced Libraries中。

六. Build openfire
openfire是用ant構建的,所以要先設置使得eclipse中每次編譯都使用內置的ant工具,保證編譯的正確執行。
1. eclipse中點擊Window->Show View->Ant
2. 在Ant 頁面點右鍵,選擇 Add Buildfiles...
3. 展開openfire/build文件夾,選擇build.xml, 點 OK.
4. 在Ant頁面, 展開Openfire XMPP Server,雙擊 openfire ant 任務


七. 創建項目Builder
1. 點擊Run->Open Run Dialog...
2. 選擇Java Application,點擊 New 按鈕
3. 在Run窗口的Main選項卡中, 修改Name文本框中的值,改成Openfire,其他名字亦可
4. 點Browse按鈕,選擇openfire, 點ok
5. 點Search按鈕,選擇Main class爲org.jivesoftware.openfire.starter.ServerStarter,點OK。(這是openfire的啓動類)
6. 點擊進入Arguments選項卡
7. 在VM arguments文本框中輸入 -DopenfireHome="${workspace_loc:openfire}/target/openfire",這個是用於eclipse執行java命令時傳遞的參數,這樣openfire程序可以通過System.getProperty(“openfireHome”)得到 openfire的本地位置。
8. 點擊進入Classpath選項卡
9. 點選User Entries,這樣Advanced...就處於可用狀態
10. 點擊Advanced...按鈕
11. 在Advanced Options頁面,選擇Add Folders, 點ok.
12. 選擇openfire/src/i18n, 點ok將這個文件夾加入到class path,同樣的方式把openfire/src/resources/jar也加到class path中。
13. 在Common選項卡中,點選Run複選框。

設置完畢,這樣以後在run這個工程的時候就會按照正確的配置進行了.

 

 

 

英文版

 

 

  1. 下載安裝JDK1.6
  2. 下載安裝Eclipse 3.3
  3. 下載openfire源代碼
    1. http http://www.igniterealtime.org/downloads/index.jsp
    2. svn http://svn.igniterealtime.org/svn/repos
  4. 創建openfire項目
    1. Select Java::Java Project and click Next.
    2. On the New Java Project window choose Create project from existing source and browse to where openfire folder is located under your workspace.
    3. In the Project name box enter exactly as openfire.
  5. 編譯openfire
    1. Click Window::Show View::Ant menu.
    2. Right-click the Ant screen and choose Add Buildfiles…
    3. Expand the openfire::build folder and select build.xml, then click OK.
    4. On the Ant screen, expand the Openfire XMPP Server and double-click on openfire ant task. The build may fail because you’re checking out the daily updates of Openfire sources, which may contain bugs. If so, wait for another day and hope that the developers discover and fix the bug; or you might dare to fix it yourself. During this first time setup, a successful build is necessary before you can proceed with the remaining tasks below.
  6. 創建項目編譯器
    1. Click Run::Open Run Dialog… or Run::Open Debug Dialog… menu. A Run window shows.
    2. Select Java Application and click on the New button.
    3. On the Main tab of the Run window, change the New_configuration name to Openfire or anything you like.
    4. Click on Project::Browse button and select openfire and click OK.
    5. Click on Main class::Search button and select ServerStarter – org.jivesoftware.openfire.starter and click OK.
    6. I’d suggest that you select Stop in main check box so that you could later verify that debugging works.
    7. Click on the Arguments tab.
    8. Enter -DopenfireHome=”${workspace_loc:openfire}/target/openfire” in the VM arguments box.
    9. Click on Classpath tab.
    10. Select User Entries so that the Advanced… button will be enabled.
    11. Click on the Advanced… button.
    12. On the Advanced Options window select Add Folders and click OK.
    13. On the Folder Selection window select openfire::src::i18n folder and click OK.
    14. Click on the Advanced… and Add Folders buttons once again to include openfire::src::resources::jar folder.
    15. Click on Common tab.
    16. Select the Debug and Run check box.
    17. Click on Apply button.
    18. Click on Close button.
  7. 運行/調試
    1. The setting is now complete for Openfire.
    2. You may test running and debugging by clicking on Run::Run History::Openfire and Run::Debug History::Openfire respectively. If you choose the later and if you follow this instruction closely, execution will stop on the main method in ServerStarter.java.

自己寫的:

     從這個網址下載源碼:http://www.igniterealtime.org/downloads/source.jsp

接下來在Eclipse中新建工程,將源碼導入:

 

 

 接下來:

openfire是用ant構建的,所以要先設置使得eclipse中每次編譯都使用內置的ant工具,保證編譯的正確執行。
1. eclipse中點擊Window->Show View->Ant
2. 在Ant 頁面點右鍵,選擇 Add Buildfiles...
3. 展開openfire/build文件夾,選擇build.xml, 點 OK.
4. 在Ant頁面, 展開Openfire XMPP Server,雙擊 openfire  任務

 

接下來:(由於我的Eclipse的版本是3.4的,所以和上邊中、英文中說的不一樣。)

 

   創建項目編譯器的路徑:

run-->Run configurations...

 

記錄一下用ant編譯openfire的過程:

 

注:我把openfire的源文件放到路徑:D:/Mayframework框架/消息組件下邊了。

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