直接開始
步驟一:下載openfire源碼
:http://www.igniterealtime.org/downloads/source.jsp 選中openfire_src_3_8_1.zip,下載(68.74 MB)
步驟二:eclipse匯入openfire
將openfire_src_3_8_1.zip解壓至eclipse工作區域中
File->New->Java Project取消掉default location的勾選狀態,並瀏覽選擇解壓好的openfire_src目錄。
步驟三:ant編譯
在openfire項目匯入進來之後,點擊Window -> Show View -> Ant然後就會顯示出Ant的視窗,在Ant 視圖中,單擊右鍵,在彈出的捷徑功能表中選擇Add Buildfiles在彈出的對話方塊中,展開openfire_src/build檔案夾,選擇build目錄下的build.xml接下來雙擊執行openfire[default] (帶一個三角符號的那個)
步驟四:引入所需jar包(coherence.jar-coherence-work.jar-tangosol.jar-)
,解壓後複製到/openfire_src/build/lib中
步驟五:配置openfireHome
eclipse中,使用快速鍵ctrl+shift+r,尋找檔案XMPPServer,修改openfireHome
if (openfireHome == null) { try { //openfireHome = verifyHome("..", jiveConfigName).getCanonicalFile(); openfireHome = verifyHome("D:/work/eclipse3.7/workspace/openfire_src/target/openfire", jiveConfigName).getCanonicalFile();//相對路徑更改為絕對路徑,用於測試服務端是否可運行 dml@2013.4.15 } catch (FileNotFoundException fe) { // Ignore. } catch (IOException ie) { // Ignore. } }
步驟六:設定啟動項
點擊openfire_src項目,在功能表列中選擇Run->Open Run Dialog (Or Run->Run Configurations)
彈出一個對話方塊,在左側菜單中右鍵點擊Java Application,選擇New建立啟動配置
1.在Run視窗的Main選項卡中, 修改最上面Name文字框中的值,改成包含要啟動的類的工程名openfire_src
(沒什麼用,就是一個標識,隨便起名字。)
2.在Run視窗的Main選項卡中,
project框中填寫:openfire_src
Main class 填寫:org.jivesoftware.openfire.starter.ServerStarter
點擊Apply應用。
3.點擊進入Arguments選項卡,在上面那個框(Program arguments:)中填寫
-D openfireHome="${workspace_loc:openfire_src}/target/openfire"
其中${workspace_loc:openfire_src} 中的 openfire_src 要根據你的項目名來進行同步修改。
eg.[-D openfireHome="D:/work/eclipse3.7/workspace/openfire_src/target/openfire"]
點擊Apply應用。
4.點擊進入Classpath選項卡,選中User Entries,然後點擊右側的Advanced按鈕,會彈出一個小框,選擇Add Folders,單擊OK。
選擇 openfire_src\src\i18n點OK 按鈕將這個檔案夾加入到Classpath選項卡中
選擇 openfire_src\src\resources\jar 目錄也加到 Classpath選項卡中
點擊Apply應用。
5.點擊進入Common選項卡中,勾選Run複選框。
點擊Apply應用,run
步驟七:測試服務端是否搭建完畢
瀏覽器中輸入http://127.0.0.1:9090
完
dml@2013.4.15