1. 程式人生 > >JDK+tomcat 環境變數配置

JDK+tomcat 環境變數配置

1.安裝JDK

安裝好JDK後,再配置JDK的環境變數:
在“我的電腦”上點右鍵—>“屬性”—>“高階”—> “環境變數(N)”。

新建系統變數JAVA_HOME:C:/Program Files/Java/jdk1.5.0_06;

新建系統變數CLASSPATH:.;%JAVA_HOME%/lib;(注意:點號表示當前目錄,不能省略)

在系統變數Path的值的前面加入以下內容:%JAVA_HOME%/bin;(注意:這裡的分號不能省略)

到這裡,JDK安裝完畢。


2.安裝Tomcat

安裝好Tomcat後,再配置Tomcat的環境變數:
在“我的電腦”上點右鍵—>“屬性”—>“高階”—> “環境變數(N)”。

新建系統變數CATALINA_HOME:D:/jakarta-tomcat-5.0.30

在系統變數CLASSPATH的值的後面加入:%CATALINA_HOME%/common/lib;

在系統變數Path的值中"%JAVA_HOME%/bin;"的後面加入以下內容:%CATALINA_HOME%/bin;

到這裡,Tomcat安裝完畢。


配置好以上環境變數之後,各系統變數的值如下:
JAVA_HOME:C:/Program Files/Java/jdk1.5.0_06
CATALINA_HOME:D:/jakarta-tomcat-5.0.30
CLASSPATH:.;%JAVA_HOME%/lib;%CATALINA_HOME%/common/lib;
Path:%JAVA_HOME%/bin;%CATALINA_HOME%/bin;%SystemRoot%/system32;%SystemRoot%;%

SystemRoot%/System32/Wbem


------------------------------------------------------------------------
測試JDK和Tomcat

開啟cmd進行測試JDK是否配置成功: 

Microsoft Windows XP [版本 5.1.2600]
(C) 版權所有 1985-2001 Microsoft Corp.

C:/Documents and Settings/Administrator>java 
Usage: java [-options] class [args...]
           (to execute a class)
   or  java [-options] -jar jarfile [args...]
           (to execute a jar file)

where options include:
    -client       to select the "client" VM
    -server       to select the "server" VM
    -hotspot      is a synonym for the "client" VM  [deprecated]
                  The default VM is client.

    -cp <class search path of directories and zip/jar files>
    -classpath <class search path of directories and zip/jar files>
                  A ; separated list of directories, JAR archives,
                  and ZIP archives to search for class files.
    -D<name>=<value>
                  set a system property
    -verbose[:class|gc|jni]
                  enable verbose output
    -version      print product version and exit
    -version:<value>
                  require the specified version to run
    -showversion  print product version and continue
    -jre-restrict-search | -jre-no-restrict-search
                  include/exclude user private JREs in the version search
    -? -help      print this help message
    -X            print help on non-standard options
    -ea[:<packagename>...|:<classname>]
    -enableassertions[:<packagename>...|:<classname>]
                  enable assertions
    -da[:<packagename>...|:<classname>]
    -disableassertions[:<packagename>...|:<classname>]
                  disable assertions
    -esa | -enablesystemassertions
                  enable system assertions
    -dsa | -disablesystemassertions
                  disable system assertions
    -agentlib:<libname>[=<options>]
                  load native agent library <libname>, e.g. -agentlib:hprof
                    see also, -agentlib:jdwp=help and -agentlib:hprof=help
    -agentpath:<pathname>[=<options>]
                  load native agent library by full pathname
    -javaagent:<jarpath>[=<options>]
                  load Java programming language agent, see java.lang.instrument

    -splash:<imagepath>
                  show splash screen with specified image

C:/Documents and Settings/Administrator>javac --輸入javac顯示下面的內容就是配置成功
用法:javac <選項> <原始檔>
其中,可能的選項包括:
  -g                         生成所有除錯資訊
  -g:none                    不生成任何除錯資訊
  -g:{lines,vars,source}     只生成某些除錯資訊
  -nowarn                    不生成任何警告
  -verbose                   輸出有關編譯器正在執行的操作的訊息
  -deprecation               輸出使用已過時的 API 的源位置
  -classpath <路徑>            指定查詢使用者類檔案和註釋處理程式的位置
  -cp <路徑>                   指定查詢使用者類檔案和註釋處理程式的位置
  -sourcepath <路徑>           指定查詢輸入原始檔的位置
  -bootclasspath <路徑>        覆蓋引導類檔案的位置
  -extdirs <目錄>              覆蓋安裝的擴充套件目錄的位置
  -endorseddirs <目錄>         覆蓋簽名的標準路徑的位置
  -proc:{none,only}          控制是否執行註釋處理和/或編譯。
  -processor <class1>[,<class2>,<class3>...]要執行的註釋處理程式的名稱;繞過預設
的搜尋程序
  -processorpath <路徑>        指定查詢註釋處理程式的位置
  -d <目錄>                    指定存放生成的類檔案的位置
  -s <目錄>                    指定存放生成的原始檔的位置
  -implicit:{none,class}     指定是否為隱式引用檔案生成類檔案
  -encoding <編碼>             指定原始檔使用的字元編碼
  -source <版本>               提供與指定版本的源相容性
  -target <版本>               生成特定 VM 版本的類檔案
  -version                   版本資訊
  -help                      輸出標準選項的提要
  -Akey[=value]              傳遞給註釋處理程式的選項
  -X                         輸出非標準選項的提要
  -J<標誌>                     直接將 <標誌> 傳遞給執行時系統


C:/Documents and Settings/Administrator>

測試Tomcat是否配置成功:

進入Tomcat目錄下的bin裡面
雙擊startup.bat