因為接案工作的需要以 JAVA 編寫一個 JSP 網站 ,為了方便程式開發及日後測試 ,
所以必須架設適當的開發環境 ,於是 本篇文章為 JAVA 開發環境在 Fedora linux 8 的架設過程筆記 ,供參考 ,歡迎討論 ,謝謝

1. 下載 JDK 6 Update 6 


    連結 
http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u6-linux-i586-rpm.bin?BundledLineItemUUID=vyRIBe.oez8AAAEasm5Le5wv&OrderID=1cdIBe.oTHQAAAEapG5Le5wv&ProductID=VXZIBe.ootIAAAEZTrBAkQve&FileName=/jdk-6u6-linux-i586-rpm.bin

2. 安裝 JDK6 Update 6 ,以下為步驟 ,請參考

[root@dns develop]# ls -lh
total 64M
-rw-r--r-- 1 root root 64M 2008-03-31 17:49 jdk-6u6-linux-i586-rpm.bin
[root@dns develop]# chmod u+x jdk-6u6-linux-i586-rpm.bin
[root@dns develop]# ls
jdk-6u6-linux-i586-rpm.bin
[root@dns develop]#

jdk-6u6-linux-i586-rpm.bin
[root@dns develop]# ./jdk-6u6-linux-i586-rpm.bin
Sun Microsystems, Inc. Binary Code License Agreement

for the JAVA SE DEVELOPMENT KIT (JDK), VERSION 6

SUN MICROSYSTEMS, INC. ("SUN") IS WILLING TO LICENSE THE
SOFTWARE IDENTIFIED BELOW TO YOU ONLY UPON THE CONDITION
THAT YOU ACCEPT ALL OF THE TERMS CONTAINED IN THIS BINARY
CODE LICENSE AGREEMENT AND SUPPLEMENTAL LICENSE TERMS
(COLLECTIVELY "AGREEMENT"). PLEASE READ THE AGREEMENT
CAREFULLY. BY DOWNLOADING OR INSTALLING THIS SOFTWARE, YOU

--- 略 (Java 授權合約內容) ---

For inquiries please contact: Sun Microsystems, Inc., 4150
Network Circle, Santa  Clara, California 95054, U.S.A.

Do you agree to the above license terms? [yes or no]
輸入 --> yes


Unpacking...
Checksumming...
Extracting...
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
  inflating: jdk-6u6-linux-i586.rpm
  inflating: sun-javadb-common-10.3.1-4.1.i386.rpm
  inflating: sun-javadb-core-10.3.1-4.1.i386.rpm
  inflating: sun-javadb-client-10.3.1-4.1.i386.rpm
  inflating: sun-javadb-demo-10.3.1-4.1.i386.rpm
  inflating: sun-javadb-docs-10.3.1-4.1.i386.rpm
  inflating: sun-javadb-javadoc-10.3.1-4.1.i386.rpm
Preparing...                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...
Installing JavaDB
Preparing...                ########################################### [100%]
   1:sun-javadb-common      ########################################### [ 17%]
   2:sun-javadb-core        ########################################### [ 33%]
   3:sun-javadb-client      ########################################### [ 50%]
   4:sun-javadb-demo        ########################################### [ 67%]
   5:sun-javadb-docs        ########################################### [ 83%]
   6:sun-javadb-javadoc     ########################################### [100%]

Java(TM) SE Development Kit 6 successfully installed.

Product Registration is FREE and includes many benefits:
* Notification of new versions, patches, and updates
* Special offers on Sun products, services and training
* Access to early releases and documentation

Product and system data will be collected. If your configuration
supports a browser, the Sun Product Registration form for
the JDK will be presented. If you do not register, none of
this information will be saved. You may also register your
JDK later by opening the register.html file (located in
the JDK installation directory) in a browser.

For more information on what data Registration collects and
how it is managed and used, see:
http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html

Press Enter to continue.....


--> 按 Enter 完成安裝

Done.
[root@dns develop]#

修改環境組態設定  ,讓你可以在 shell 端直接輸入 java build or 執行 所編寫的 java 程式. 

[root@dns develop]# cd ~
(切回家目錄)
[root@dns ~]# joe .bash
.bash_history  .bash_logout   .bash_profile  .bashrc
[root@dns ~]# joe .bash_profile
(使用 joe 編輯器載入 .bash_profile 檔案) 

--- .bash_profile 檔案原始內容 ---

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME

--- .bash_profile 檔案原始內容 ---

請在原始設定的內容加入以下的內容 

--- 需要加入在 .bash_profile 的區段內容 ---

# for java develop environment

PATH=/usr/java/jdk1.6.0_06/bin:$PATH
export JAVA_HOME=/usr/java/jdk1.6.0_06
export CLASSPATH=/usr/java/jdk1.6.0_06/lib/tools.jar:/usr/java/jdk1.6.0_06/jre/:.

--- 需要加入在 .bash_profile 的區段內容 (結束) --- 

加入完成後 ,請重新簽入 Linux 主機
並且 ,使用 joe 編寫一個 test.java 的測試檔案 ,內容如下:

public class test
{
  public static void main(String[] args)
  {
    System.out.println("Hello world");
  }
}

編寫完成 ,請儲存檔案 ,並且 ,輸入下列指令測試, 確認是否可以出現 Hello World 字樣

[root@dns test]# javac test.java
[root@dns test]# java test
Hello world
[root@dns test]#

若能出現 Hello World 字樣 ,代表安裝無誤 ,若執行 java test 出現如下訊息

[root@dns test]# java test
Exception in thread "main" java.lang.NoClassDefFoundError: test/java
Caused by: java.lang.ClassNotFoundException: test.java
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
[root@dns test]#

則請確認 在 .bash_profile 的設定值 CALSSPATH 是否有在末端加上 :. 若沒有請補上 ,如下請參考
export CLASSPATH=/usr/java/jdk1.6.0_06/lib/tools.jar:/usr/java/jdk1.6.0_06/jre/:.

3.  取得 tomcat   相關元件
 從 cle.linux.org.tw 的路徑  ftp://cle.linux.org.tw/pub/fedora/linux/releases/8/Fedora/i386/os/Packages/ 取得必須的檔案

ncftp ...edora/i386/os/Packages > mget *tomcat* *jakarta*
...ons-collections-tomcat5-3.1-9jpp.2.fc7.1.i386.rpm:   61.40 kB  258.79 kB/s
...a-commons-dbcp-tomcat5-1.2.1-10jpp.2.fc8.i386.rpm:  215.93 kB  473.64 kB/s
jakarta-commons-pool-tomcat5-1.3-9jpp.3.fc8.i386.rpm:   95.12 kB  351.08 kB/s
tomcat-native-1.1.10-1.fc8.i386.rpm:                    58.92 kB  245.54 kB/s
tomcat5-5.5.23-9jpp.4.fc8.i386.rpm:                    414.19 kB  542.60 kB/s
tomcat5-admin-webapps-5.5.23-9jpp.4.fc8.i386.rpm:        1.89 MB  666.43 kB/s
tomcat5-common-lib-5.5.23-9jpp.4.fc8.i386.rpm:         182.59 kB  462.87 kB/s
tomcat5-jasper-5.5.23-9jpp.4.fc8.i386.rpm:             927.96 kB  661.22 kB/s
tomcat5-jasper-eclipse-5.5.23-9jpp.4.fc8.i386.rpm:       4.16 MB  728.51 kB/s
tomcat5-jsp-2.0-api-5.5.23-9jpp.4.fc8.i386.rpm:         90.41 kB  312.70 kB/s
tomcat5-server-lib-5.5.23-9jpp.4.fc8.i386.rpm:           3.21 MB  716.50 kB/s
tomcat5-servlet-2.4-api-5.5.23-9jpp.4.fc8.i386.rpm:    145.16 kB  437.77 kB/s
tomcat5-webapps-5.5.23-9jpp.4.fc8.i386.rpm:              1.10 MB  664.85 kB/s
ncftp ...edora/i386/os/Packages >

以下為將要進行安裝的 tomcat rpm 套件

[root@dns tomcat]# ls
jakarta-commons-beanutils-1.7.0-5jpp.1.i386.rpm
jakarta-commons-beanutils-javadoc-1.7.0-5jpp.1.i386.rpm
jakarta-commons-cli-1.0-6jpp_10.fc6.i386.rpm
jakarta-commons-codec-1.3-8jpp.2.fc8.i386.rpm
jakarta-commons-collections-3.1-9jpp.2.fc7.1.i386.rpm
jakarta-commons-collections-javadoc-3.1-9jpp.2.fc7.1.i386.rpm
jakarta-commons-collections-tomcat5-3.1-9jpp.2.fc7.1.i386.rpm
jakarta-commons-daemon-1.0.1-6jpp.4.fc8.i386.rpm
jakarta-commons-daemon-javadoc-1.0.1-6jpp.4.fc8.i386.rpm
jakarta-commons-dbcp-1.2.1-10jpp.2.fc8.i386.rpm
jakarta-commons-dbcp-javadoc-1.2.1-10jpp.2.fc8.i386.rpm
jakarta-commons-dbcp-tomcat5-1.2.1-10jpp.2.fc8.i386.rpm
jakarta-commons-digester-1.7-6jpp.2.i386.rpm
jakarta-commons-digester-javadoc-1.7-6jpp.2.i386.rpm
jakarta-commons-discovery-0.3-4jpp.1.i386.rpm
jakarta-commons-el-1.0-8jpp.2.fc8.i386.rpm
jakarta-commons-el-javadoc-1.0-8jpp.2.fc8.i386.rpm
jakarta-commons-fileupload-1.0-6jpp.1.i386.rpm
jakarta-commons-fileupload-javadoc-1.0-6jpp.1.i386.rpm
jakarta-commons-httpclient-3.0.1-1jpp.2.fc8.i386.rpm
jakarta-commons-io-1.2-3jpp.1.fc7.noarch.rpm
jakarta-commons-lang-2.1-6jpp.1.fc7.i386.rpm
jakarta-commons-lang-javadoc-2.1-6jpp.1.fc7.i386.rpm
jakarta-commons-launcher-1.1-1jpp.3.fc8.i386.rpm
jakarta-commons-launcher-javadoc-1.1-1jpp.3.fc8.i386.rpm
jakarta-commons-logging-1.0.4-6jpp.4.fc8.i386.rpm
jakarta-commons-logging-javadoc-1.0.4-6jpp.4.fc8.i386.rpm
jakarta-commons-modeler-2.0-3jpp.2.fc8.i386.rpm
jakarta-commons-modeler-javadoc-2.0-3jpp.2.fc8.i386.rpm
jakarta-commons-pool-1.3-9jpp.3.fc8.i386.rpm
jakarta-commons-pool-javadoc-1.3-9jpp.3.fc8.i386.rpm
jakarta-commons-pool-tomcat5-1.3-9jpp.3.fc8.i386.rpm
jakarta-commons-validator-1.1.4-5jpp.2.fc8.i386.rpm
jakarta-commons-validator-javadoc-1.1.4-5jpp.2.fc8.i386.rpm
jakarta-oro-2.0.8-3jpp.1.i386.rpm
jakarta-oro-javadoc-2.0.8-3jpp.1.i386.rpm
jakarta-taglibs-standard-1.1.1-7jpp.1.i386.rpm
jakarta-taglibs-standard-javadoc-1.1.1-7jpp.1.i386.rpm
tomcat5-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-admin-webapps-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-common-lib-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-jasper-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-jasper-eclipse-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-jsp-2.0-api-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-server-lib-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-servlet-2.4-api-5.5.23-9jpp.4.fc8.i386.rpm
tomcat5-webapps-5.5.23-9jpp.4.fc8.i386.rpm
tomcat-native-1.1.10-1.fc8.i386.rpm


4. 安裝 tomcat
   tomcat 為 jsp 的 web server 套件 ,切換至步驟三下載 tomcat 的目錄 ,再以指令  rpm -ivh --nodeps --force *.rpm 即可快速安裝該目錄的所有  rpm 檔案

[root@dns tomcat]# rpm -ivh --force --nodeps *.rpm
Preparing...                ########################################### [100%]
   1:tomcat5-jasper-eclipse ########################################### [  2%]
   2:jakarta-taglibs-standar########################################### [  4%]
   3:jakarta-oro-javadoc    ########################################### [  6%]
   4:jakarta-commons-validat########################################### [  8%]
   5:jakarta-commons-pool-ja########################################### [ 10%]
   6:jakarta-commons-modeler########################################### [ 13%]
   7:jakarta-commons-logging########################################### [ 15%]
   8:jakarta-commons-launche########################################### [ 17%]
   9:jakarta-commons-lang-ja########################################### [ 19%]
  10:jakarta-commons-io     ########################################### [ 21%]
  11:jakarta-commons-fileupl########################################### [ 23%]
  12:jakarta-commons-el-java########################################### [ 25%]
  13:jakarta-commons-digeste########################################### [ 27%]
  14:jakarta-commons-dbcp-ja########################################### [ 29%]
  15:jakarta-commons-daemon-########################################### [ 31%]
  16:jakarta-commons-collect########################################### [ 33%]
  17:jakarta-commons-beanuti########################################### [ 35%]
  18:jakarta-commons-logging########################################### [ 38%]
  19:tomcat5-servlet-2.4-api########################################### [ 40%]
  20:jakarta-commons-collect########################################### [ 42%]
  21:jakarta-commons-beanuti########################################### [ 44%]
  22:jakarta-commons-digeste########################################### [ 46%]
  23:tomcat5-jasper         ########################################### [ 48%]
  24:tomcat5-jsp-2.0-api    ########################################### [ 50%]
  25:jakarta-commons-pool-to########################################### [ 52%]
  26:jakarta-commons-dbcp-to########################################### [ 54%]
  27:jakarta-commons-collect########################################### [ 56%]
  28:jakarta-taglibs-standar########################################### [ 58%]
  29:jakarta-commons-modeler########################################### [ 60%]
  30:tomcat5-server-lib     ########################################### [ 63%]
  31:jakarta-oro            ########################################### [ 65%]
  32:jakarta-commons-pool   ########################################### [ 67%]
  33:jakarta-commons-launche########################################### [ 69%]
  34:jakarta-commons-lang   ########################################### [ 71%]
  35:jakarta-commons-el     ########################################### [ 73%]
  36:tomcat5-common-lib     ########################################### [ 75%]
  37:jakarta-commons-daemon ########################################### [ 77%]
  38:tomcat5                ########################################### [ 79%]
/usr/bin/build-jar-repository: error: Could not find javamail Java extension for this JVM
/usr/bin/build-jar-repository: error: Some specified jars were not found for this jvm
/usr/bin/build-jar-repository: error: Could not find eclipse-ecj Java extension for this JVM
/usr/bin/build-jar-repository: error: Some specified jars were not found for this jvm
  39:jakarta-commons-cli    ########################################### [ 81%]
  40:jakarta-commons-codec  ########################################### [ 83%]
  41:jakarta-commons-dbcp   ########################################### [ 85%]
  42:jakarta-commons-discove########################################### [ 88%]
  43:jakarta-commons-fileupl########################################### [ 90%]
  44:jakarta-commons-httpcli########################################### [ 92%]
  45:jakarta-commons-validat########################################### [ 94%]
  46:tomcat5-admin-webapps  ########################################### [ 96%]
/usr/bin/build-jar-repository: error: Could not find struts Java extension for this JVM
/usr/bin/build-jar-repository: error: Some specified jars were not found for this jvm
  47:tomcat5-webapps        ########################################### [ 98%]
  48:tomcat-native          ########################################### [100%]

5. 修改組態 tomcat 設定

[root@dns tomcat5]# pwd
/etc/tomcat5
[root@dns tomcat5]# joe tomcat5.conf

透過 joe 載入 tomcat5.conf 組態檔 ,修改它 ,以符合開發環境需求

請將原本的 JAVA_HOME="/usr/lib/jvm/java"
修改成 JAVA_HOME="/usr/java/jdk1.6.0_06/"


6. 測試 tomcat 與 jsp page

完成以上工作後 ,輸入指令 service tomcat5 start 以啟動 tomcat5 service 
啟動之後 ,可以透過瀏覽器測試是否能夠正常運作

Tomcat default main page (example : http://192.168.1.99:8080/



Jsp sample page (example : http://192.168.1.99:8080/jsp-examples/ )








arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Frank 的頭像
    Frank

    經驗交流分享與備忘

    Frank 發表在 痞客邦 留言(0) 人氣()