1 / 14

簡易的 JBoss 安裝與部署

簡易的 JBoss 安裝與部署. 安裝 Step 1. 下載 J2SE JDK 5.O 並安裝 http://java.sun.com/j2se/1.5.0/download.jsp 下載 JBoss 並解壓縮 (.zip 檔 ) http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942&release_id=365509. 安裝 Step 2. 在環境變數中設定: JBOSS_HOME = C:jboss-4.0.3SP1

roscoe
Download Presentation

簡易的 JBoss 安裝與部署

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 簡易的JBoss安裝與部署

  2. 安裝Step 1 • 下載J2SE JDK 5.O並安裝 http://java.sun.com/j2se/1.5.0/download.jsp • 下載JBoss並解壓縮 (.zip檔) http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=16942&release_id=365509

  3. 安裝Step 2 • 在環境變數中設定: JBOSS_HOME = C:\jboss-4.0.3SP1 JAVA_HMOE = C:\Program Files\Java\jdk1.5.0_06 (以上為預設的安裝路徑,有更改就用自訂的) PATH = %JAVA_HOME%\bin CLASSPATH = .;%JAVA_HOME%\lib • 設定完成按確定

  4. 安裝Step 3 • 到C:\jboss-4.0.3SP1\bin的目錄中執行run.bat檔案起動JBoss,將會跳出以下視窗:

  5. 安裝Step 4 • 開啟瀏覽器,輸入 http://localhost:8080/ 出現以下畫面即表示JBoss安裝成功。

  6. 安裝Step 5 • 關掉「起動JBoss」視窗的方法:Ctrl+C。

  7. 部署Step 1 • 命名一個新資料夾,這裡用TestRoot,並在Test中再建一個新資料夾WEB-INF, 再至WEB-INF中建一個新資料夾classes。放在任何位置。例如:C:\TestRoot\WEB-INF\classes • 其中WEB-INF和classes的名稱是固定的,這是部署的問題,以後上課應該會提到。

  8. 部署Step 2 • 撰寫第一個servlet程式,副檔名 .java,並編譯產生出.class檔。 • 在編譯之前別忘了要在環境變數中設定: PATH = %JBOSS_HOME%\server\default\lib\javax.servlet.jar 這樣才能import servlet的相關套件。

  9. 部署Step 2 (servlet範例.) 我把MyFirstServlet.class放在test的資料夾中 package test; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; publicclass MyFirstServlet extends HttpServlet { publicvoid doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println("<html>"); out.println("<body>"); out.println("<head>"); out.println("<title>Servlet Exercise</title>"); out.println("</head>"); out.println("<body>"); out.println("<h2>This is my first Servlet!</h2>"); out.println("</body>"); } }

  10. 部署Step 3 • 寫一個web.xml (部署敘述檔),內容為: <?xml version="1.0" encoding="ISO-8859-1"?> <web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2eehttp://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4"> <servlet> <servlet-name>firstTest</servlet-name> <servlet-class>test.MyFirstServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>firstTest</servlet-name> <url-pattern>/Test.do</url-pattern> </servlet-mapping> </web-app> 固定的,照抄就好 自訂的名字 和上面的要一樣 你寫的servlet的名字,記得package的名稱要完整的寫上 你要在網頁上顯示的網址名稱,自訂,但前面一定要加”/”

  11. 部署Step 4 • 把web.xml放到WEB-INF資料夾下。test\MyFirstServlet.class放在classes的資料夾下。 • 整個結構如下: C:\TestRoot |-WEB-INF |-classes |-test |-MyFirstServlet.class |-web.xml

  12. 部署Step 5 • 現在要製作.war檔,打開命令提示字元,並做以下動作: • 此時在C:\TestRoot\下就會產生一個TestRoot.war,將.war檔複製到C:\jboss-4.0.3SP1\server\default\deploy\下。

  13. 部署Step 6 • 重新起動JBoss。 • 開啟瀏覽器,輸入http://localhost:8080/TestRoot/Test.do

  14. 目前只研究到這樣…有問題請到ST507–AAJC • 助教mail:g942820@thu.edu.tw

More Related