Linux安装JDK和Tomcat

时间:2022-03-04 09:06:47

一.下载JDK

1.登录Sun的JDK官方下载网址:http://www.oracle.com/technetwork/java/archive-139210.html

2.下载jdk-1_5_0_07-linux-i586-rpm.bin文件

 

二.安装JDK

1.增加jdk-1_5_0_07-linux-i586-rpm.bin文件的可执行权限

#root> chmod 755 jdk-1_5_0_07-linux-i586-rpm.bin

2.执行jdk-1_5_0_07-linux-i586-rpm.bin

#root> ./ jdk-1_5_0_07-linux-i586-rpm.bin

3.安装PRM包文件

#root> rpm -ivh jdk-1_5_0_07-linux-i586.rpm

 

 

 

Last login: Wed Jun 20 15:59:55 2012 from 10.223.15.220
[root@V8bs2 ~]# ls
1  anaconda-ks.cfg  Desktop  install.log  install.log.syslog
[root@V8bs2 ~]# cd ../
[root@V8bs2 /]# ls
bin   dev  home    lib         media  mnt  proc  sbin     srv  tmp  v8bs    var
boot  etc  initrd  lost+found  misc   opt  root  selinux  sys  usr  v8bsex
[root@V8bs2 /]# cd usr
[root@V8bs2 usr]# ls
bin  games    java      lib      local       sbin   src  X11R6
etc  include  kerberos  libexec  lost+found  share  tmp
[root@V8bs2 usr]# cd java
[root@V8bs2 java]# ls
jdk-6u18-linux-i586-rpm.bin

[root@V8bs2 java]# chmod 755 jdk-6u18-linux-i586-rpm.bin [root@V8bs2 java]# ./jdk-6u18-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 USING THE SOFTWARE YOU ACKNOWLEDGE THAT YOU HAVE READ THE TERMS AND AGREE TO THEM. IF YOU ARE AGREEING TO THESE TERMS ON BEHALF OF A COMPANY OR OTHER LEGAL ENTITY, YOU REPRESENT THAT YOU HAVE THE LEGAL AUTHORITY TO BIND THE LEGAL ENTITY TO THESE TERMS. IF YOU DO NOT HAVE SUCH AUTHORITY, OR IF YOU DO NOT WISH TO BE BOUND BY THE TERMS, THEN YOU MUST NOT USE THE SOFTWARE ON THIS SITE OR ANY OTHER MEDIA ON WHICH THE SOFTWARE IS CONTAINED.

1. DEFINITIONS. "Software" means the identified above in binary form, any other machine readable materials (including, but not limited to, libraries, source files, header files, and data files), any updates or error corrections provided by Sun, and any user manuals, programming guides and other documentation provided to you by Sun under this Agreement.  "General Purpose Desktop Computers and Servers" means computers, including desktop and laptop computers, or servers, used for general computing functions under end user control (such as but not specifically limited to email, general purpose Internet browsing, and office suite productivity tools). The use of Software in systems and solutions that provide dedicated functionality (other than as mentioned above) or designed for use in embedded or function-specific software applications, for example but not limited to: Software embedded in or bundled with industrial control systems, wireless mobile telephones, wireless handheld devices, netbooks, kiosks, TV/STB, Blu-ray Disc devices, telematics and network control switching equipment, printers and storage management systems, and other related systems are excluded from this definition and not licensed under this Agreement.  "Programs" means Java technology applets and applications intended to run on the Java Platform Standard Edition (Java SE) platform on Java-enabled General Purpose Desktop Computers and Servers.

2. LICENSE TO USE. Subject to the terms and conditions of this Agreement, including, but not limited to the Java Technology Restrictions of the Supplemental License Terms, Sun grants you a non-exclusive, non-transferable, limited license without license fees to reproduce and use internally Software complete and unmodified for the sole purpose of running Programs. Additional licenses for developers and/or publishers are granted in the Supplemental License Terms.

3. RESTRICTIONS. Software is confidential and copyrighted. Title to Software and all associated intellectual property rights is retained by Sun and/or its licensors. Unless enforcement is prohibited by applicable law, you may not modify, decompile, or reverse engineer Software. You acknowledge that Licensed Software is not designed or intended for use in the design, construction, operation or maintenance of any nuclear facility. Sun Microsystems, Inc. disclaims any express or implied warranty of fitness for such uses. No right, title or interest in or to any trademark, service mark, logo or trade name of Sun or its licensors is granted under this Agreement. Additional restrictions for developers and/or publishers licenses are set forth in the Supplemental License Terms.

4. LIMITED WARRANTY. Sun warrants to you that for a period of ninety (90) days from the date of purchase, as evidenced by a copy of the receipt, the media on which Software is furnished (if any) will be free of defects in materials and workmanship under normal use. Except for the foregoing, Software is provided "AS IS". Your exclusive remedy and Sun's entire liability under this limited warranty will be at Sun's option to replace Software media or refund the fee paid for Software. Any implied warranties on the Software are limited to 90 days. Some states do not allow limitations on duration of an implied warranty, so the above may not apply to you. This limited warranty gives you specific legal rights. You may have others, which vary from state to state.

5. DISCLAIMER OF WARRANTY. UNLESS SPECIFIED IN THIS AGREEMENT, ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT THESE DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

6. LIMITATION OF LIABILITY. TO THE EXTENT NOT PROHIBITED BY LAW, IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR SPECIAL, INDIRECT, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF OR RELATED TO THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. In no event will Sun's liability to you, whether in contract, tort (including negligence), or otherwise, exceed the amount paid by you for Software under this Agreement. The foregoing limitations will apply even if the above stated warranty fails of its essential purpose. Some states do not allow the exclusion of incidental or consequential damages, so some of the terms above may not be applicable to you.

7. TERMINATION. This Agreement is effective until terminated. You may terminate this Agreement at any time by destroying all copies of Software. This Agreement will terminate immediately without notice from Sun if you fail to comply with any provision of this Agreement. Either party may terminate this Agreement immediately should any Software become, or in either party's opinion be likely to become, the subject of a claim of infringement of any intellectual property right. Upon Termination, you must destroy all copies of Software.

8. EXPORT REGULATIONS. All Software and technical data delivered under this Agreement are subject to US export control laws and may be subject to export or import regulations in other countries. You agree to comply strictly with all such laws and regulations and acknowledge that you have the responsibility to obtain such licenses to export, re-export, or import as may be required after delivery to you.

9. TRADEMARKS AND LOGOS. You acknowledge and agree as between you and Sun that Sun owns the SUN, SOLARIS, JAVA, JINI, FORTE, and iPLANET trademarks and all SUN, SOLARIS, JAVA, JINI, FORTE, and iPLANET-related trademarks, service marks, logos and other brand designations ("Sun Marks"), and you agree to comply with the Sun Trademark and Logo Usage Requirements currently located at http://www.sun.com/policies/trademarks. Any use you make of the Sun Marks inures to Sun's benefit.

10. U.S. GOVERNMENT RESTRICTED RIGHTS. If Software is being acquired by or on behalf of the U.S. Government or by a U.S. Government prime contractor or subcontractor (at any tier), then the Government's rights in Software and accompanying documentation will be only as set forth in this Agreement; this is in accordance with 48 CFR 227.7201 through 227.7202-4 (for Department of Defense (DOD) acquisitions) and with 48 CFR 2.101 and 12.212 (for non-DOD acquisitions).

11. GOVERNING LAW. Any action related to this Agreement will be governed by California law and controlling U.S. federal law. No choice of law rules of any jurisdiction will apply.

12. SEVERABILITY. If any provision of this Agreement is held to be unenforceable, this Agreement will remain in effect with the provision omitted, unless omission would frustrate the intent of the parties, in which case this Agreement will immediately terminate.

13. INTEGRATION. This Agreement is the entire agreement between you and Sun relating to its subject matter. It supersedes all prior or contemporaneous oral or written communications, proposals, representations and warranties and prevails over any conflicting or additional terms of any quote, order, acknowledgment, or other communication between the parties relating to its subject matter during the term of this Agreement. No modification of this Agreement will be binding, unless in writing and signed by an authorized representative of each party.

SUPPLEMENTAL LICENSE TERMS

These Supplemental License Terms add to or modify the terms of the Binary Code License Agreement. Capitalized terms not defined in these Supplemental Terms shall have the same meanings ascribed to them in the Binary Code License Agreement . These Supplemental Terms shall supersede any inconsistent or conflicting terms in the Binary Code License Agreement, or in any license contained within the Software.

A. Software Internal Use and Development License Grant. Subject to the terms and conditions of this Agreement and restrictions and exceptions set forth in the Software "README" file incorporated herein by reference, including, but not limited to the Java Technology Restrictions of these Supplemental Terms, Sun grants you a non-exclusive, non-transferable, limited license without fees to reproduce internally and use internally the Software complete and unmodified for the purpose of designing, developing, and testing your Programs.

B. License to Distribute Software. Subject to the terms and conditions of this Agreement and restrictions and exceptions set forth in the Software README file, including, but not limited to the Java Technology Restrictions of these Supplemental Terms, Sun grants you a non-exclusive, non-transferable, limited license without fees to reproduce and distribute the Software, provided that (i) you distribute the Software complete and unmodified and only bundled as part of, and for the sole purpose of running, your Programs, (ii) the Programs add significant and primary functionality to the Software, (iii) you do not distribute additional software intended to replace any component(s) of the Software, (iv) you do not remove or alter any proprietary legends or notices contained in the Software, (v) you only distribute the Software subject to a license agreement that protects Sun's interests consistent with the terms contained in this Agreement, and (vi) you agree to defend and indemnify Sun and its licensors from and against any damages, costs, liabilities, settlement amounts and/or expenses (including attorneys' fees) incurred in connection with any claim, lawsuit or action by any third party that arises or results from the use or distribution of any and all Programs and/or Software.

C. License to Distribute Redistributables. Subject to the terms and conditions of this Agreement and restrictions and exceptions set forth in the Software README file, including but not limited to the Java Technology Restrictions of these Supplemental Terms, Sun grants you a non-exclusive, non-transferable, limited license without fees to reproduce and distribute those files specifically identified as redistributable in the Software "README" file ("Redistributables") provided that: (i) you distribute the Redistributables complete and unmodified, and only bundled as part of Programs, (ii) the Programs add significant and primary functionality to the Redistributables, (iii) you do not distribute additional software intended to supersede any component(s) of the Redistributables (unless otherwise specified in the applicable README file), (iv) you do not remove or alter any proprietary legends or notices contained in or on the Redistributables, (v) you only distribute the Redistributables pursuant to a license agreement that protects Sun's interests consistent with the terms contained in the Agreement, (vi) you agree to defend and indemnify Sun and its licensors from and against any damages, costs, liabilities, settlement amounts and/or expenses (including attorneys' fees) incurred in connection with any claim, lawsuit or action by any third party that arises or results from the use or distribution of any and all Programs and/or Software.

D. Java Technology Restrictions.  You may not create, modify, or change the behavior of, or authorize your licensees to create, modify, or change the behavior of, classes, interfaces, or subpackages that are in any way identified as "java", "javax", "sun" or similar convention as specified by Sun in any naming convention designation.

E. Distribution by Publishers. This section pertains to your distribution of the Software with your printed book or magazine (as those terms are commonly used in the industry) relating to Java technology ("Publication"). Subject to and conditioned upon your compliance with the restrictions and obligations contained in the Agreement, in addition to the license granted in Paragraph 1 above, Sun hereby grants to you a non-exclusive, nontransferable limited right to reproduce complete and unmodified copies of the Software on electronic media (the "Media") for the sole purpose of inclusion and distribution with your Publication(s), subject to the following terms: (i) You may not distribute the Software on a stand-alone basis; it must be distributed with your Publication(s); (ii) You are responsible for downloading the Software from the applicable Sun web site; (iii) You must refer to the Software as JavaTM SE Development Kit 6; (iv) The Software must be reproduced in its entirety and without any modification whatsoever (including, without limitation, the Binary Code License and Supplemental License Terms accompanying the Software and proprietary rights notices contained in the Software); (v) The Media label shall include the following information: Copyright 2006, Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Sun, Sun Microsystems, the Sun logo, Solaris, Java, the Java Coffee Cup logo, J2SE, and all trademarks and logos based on Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This information must be placed on the Media label in such a manner as to only apply to the Sun Software; (vi) You must clearly identify the Software as Sun's product on the Media holder or Media label, and you may not state or imply that Sun is responsible for any third-party software contained on the Media; (vii) You may not include any third party software on the Media which is intended to be a replacement or substitute for the Software; (viii) You shall indemnify Sun for all damages arising from your failure to comply with the requirements of this Agreement. In addition, you shall defend, at your expense, any and all claims brought against Sun by third parties, and shall pay all damages awarded by a court of competent jurisdiction, or such settlement amount negotiated by you, arising out of or in connection with your use, reproduction or distribution of the Software and/or the Publication. Your obligation to provide indemnification under this section shall arise provided that Sun: (a) provides you prompt notice of the claim; (b) gives you sole control of the defense and settlement of the claim; (c) provides you, at your expense, with all available information, assistance and authority to defend; and (d) has not compromised or settled such claim without your prior written consent; and (ix) You shall provide Sun with a written notice for each Publication; such notice shall include the following information: (1) title of Publication, (2) author(s), (3) date of Publication, and (4) ISBN or ISSN numbers. Such notice shall be sent to Sun Microsystems, Inc., 4150 Network Circle, M/S USCA12-110, Santa Clara, California 95054, U.S.A , Attention: Contracts Administration.

F. Source Code. Software may contain source code that, unless expressly licensed for other purposes, is provided solely for reference purposes pursuant to the terms of this Agreement. Source code may not be redistributed unless expressly provided for in this Agreement.

G. Third Party Code. Additional copyright notices and license terms applicable to portions of the Software are set forth in the THIRDPARTYLICENSEREADME.txt file. In addition to any terms and conditions of any third party opensource/freeware license identified in the THIRDPARTYLICENSEREADME.txt file, the disclaimer of warranty and limitation of liability provisions in paragraphs 5 and 6 of the  Binary Code License Agreement shall apply to all Software in this distribution.

H. Termination for Infringement. Either party may terminate this Agreement immediately should any Software become, or in either party's opinion be likely to become, the subject of a claim of infringement of any intellectual property right.

I. Installation and Auto-Update.  The Software's installation and auto-update processes transmit a limited amount of data to Sun (or its service provider) about those specific processes to help Sun understand and optimize them.  Sun does not associate the data with personally identifiable information.  You can find more information about the data Sun collects at http://java.com/data/.

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

Please enter "yes" or "no".
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-6u18-linux-i586.rpm 
  inflating: sun-javadb-common-10.5.3-0.2.i386.rpm 
  inflating: sun-javadb-core-10.5.3-0.2.i386.rpm 
  inflating: sun-javadb-client-10.5.3-0.2.i386.rpm 
  inflating: sun-javadb-demo-10.5.3-0.2.i386.rpm 
  inflating: sun-javadb-docs-10.5.3-0.2.i386.rpm 
  inflating: sun-javadb-javadoc-10.5.3-0.2.i386.rpm 
婧栧倷涓?..                ########################################### [100%]
        宸茬稉瀹夎 jdk-1.7.0_04-fcs 濂椾欢锛堟瘮 jdk-1.6.0_18-fcs 鏂帮級
        妾旀 /etc/init.d/jexec 鏈夋墍琛濈獊锛屽湪瑭﹀湒瀹夎 jdk-1.6.0_18-fcs 鏅傦紙渚嗚嚜濂椾欢 jdk-1.7.0_04-fcs锛?
                                        Installing JavaDB
婧栧倷涓?..                ########################################### [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%]
 
Done.

[root@V8bs2 java]# ls
jdk-6u18-linux-i586.rpm                sun-javadb-core-10.5.3-0.2.i386.rpm
jdk-6u18-linux-i586-rpm.bin            sun-javadb-demo-10.5.3-0.2.i386.rpm
sun-javadb-client-10.5.3-0.2.i386.rpm  sun-javadb-docs-10.5.3-0.2.i386.rpm
sun-javadb-common-10.5.3-0.2.i386.rpm  sun-javadb-javadoc-10.5.3-0.2.i386.rpm

 [root@V8bs2 java]# rpm -qa|grep jdk
jdk-1.7.0_04-fcs
[root@V8bs2 java]# rpm -e --nodeps jdk-1.7.0_04-fcs
[root@V8bs2 java]# rpm -qa|grep jdk
[root@V8bs2 java]# ls
jdk-6u18-linux-i586.rpm                sun-javadb-core-10.5.3-0.2.i386.rpm
jdk-6u18-linux-i586-rpm.bin            sun-javadb-demo-10.5.3-0.2.i386.rpm
sun-javadb-client-10.5.3-0.2.i386.rpm  sun-javadb-docs-10.5.3-0.2.i386.rpm
sun-javadb-common-10.5.3-0.2.i386.rpm  sun-javadb-javadoc-10.5.3-0.2.i386.rpm

[root@V8bs2 java]# rpm -ivh jdk-6u18-linux-i586.rpm
婧栧倷涓?..                ########################################### [100%]
   1:jdk                    ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        plugin.jar...
        javaws.jar...
        deploy.jar...


[root@V8bs2 java]# ls
default                                sun-javadb-common-10.5.3-0.2.i386.rpm
jdk1.6.0_18                            sun-javadb-core-10.5.3-0.2.i386.rpm
jdk-6u18-linux-i586.rpm                sun-javadb-demo-10.5.3-0.2.i386.rpm
jdk-6u18-linux-i586-rpm.bin            sun-javadb-docs-10.5.3-0.2.i386.rpm
latest                                 sun-javadb-javadoc-10.5.3-0.2.i386.rpm
sun-javadb-client-10.5.3-0.2.i386.rpm

重启 reboot

 [root@V8bs2 ~]# java -version
java version "1.6.0_18"
Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
Java HotSpot(TM) Server VM (build 16.0-b13, mixed mode)

三.配置环境变量PATH,JAVA_HOME,CLASSPATH

配置环境变量有三种:

1.修改/etc/profile文件(系统有效)

(1)#root > vi /etc/profile

(2)使用VI编辑器在profile文件最后添加以下语句:

#set java environment
JAVA_HOME=/usr/java/jdk1.6.0_18
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.$JAVA_HOME/lib/dt.jar:JAVA_HOME/lib/tools.jar
export JAVA_HOME CLASSPATH PATH

 

(3)重新登录

[注意]

<1>Linux下环境变量使用:分隔路径,不同于Windows下的;

<2>Linux使用($+环境变量名)来引用原来变量的值,Windows则是使用%+环境变量名+%.比如$PATH和%PATH%

<3>CLASSPATH中不能存在空格,如Windows下的C:\Documents and Settings\seagar\jdk1.5将是不合法的路径名

<4>CLASSPATH中的当前目录"."不能忽略

<5>export把环境变量导出为全局变量

<6>大小写严格区分

2.修改.bashrc文件(个人用户有效)

(1)#root > vi /home/seagar/.bashrc

(2)使用VI编辑器在.bashrc文件中添加以下语句:

JAVA_HOME=/usr/java/jdk1.5

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.$JAVA_HOME/lib/dt.jar:JAVA_HOME/lib/tools.jar export JAVA_HOME,PATH,CLASSPAT

3.直接在shell修改(当前Shell有效)

export JAVA_HOME=/usr/java/jdk1.5

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.$JAVA_HOME/lib/dt.jar:JAVA_HOME/lib/tools.jar

 

查看是否安装成功

[root@V8bs2 java]# java -version

四.测试安装情况

1.java -version查看版本号

2.使用VI编辑器编写一个Java程序

(1)#root > vi Hello.java

(2)编写程序

public class Hello {     

  public static void main(String[] args)     

  {          

     System.out.println("Hello");     

  }

}

3.编译:javac Hello.java

4.执行:java Hello

 

五.卸载jdk

   卸载rpm版的jdk:

   #rpm -qa|grep jdk

   显示:jdk-1.6.0_10-fcs

   这就说明了你安装了jdk,下面卸载了它,    卸载:#rpm -e  --nodeps  jdk-1.6.0_10-fcs

 

 

2.TOMCAT

一,安装前的准备:

1,Linux版本:[root@tpwb /]# uname -r 2.6.9-34.EL(版本内核)

2,tomcat版本:jakarta-tomcat-5.0.28.tar(大小:10.2M)

你可以去http://jakarta.apache.org/tomcat 下载

 

 二,tomcat的安装 安装前看看Tomcat安装的信息,上面也有关于Tomcat安装的信息,可以作为参考。  

//从一个Linux复制文件到另一个Linux:scp  root@192.168.1.240:/zsk/hollykm/test.txt  /home/test_copy.txt

3,下面开始安装。

[root@tpwb ~]# cd /usr/local [root@tpwb local]# ls

bin     games      lib         lost+found     sbin      src etc     include     jakarta-tomcat-5.0.28.tar.gz     libexec     man            share

我把j2sdk-1_4_2_04-linux-i586-rpm.bin放在local目录下,你也可以放在其他地方。  

第一步: 首先解压缩。

[root@tpwb local]# tar -zxvf jakarta-tomcat-5.0.28.tar.gz

[root@tpwb local]# ls

bin     games       jakarta-tomcat-5.0.28            lib         lost+found     sbin      src etc     include     jakarta-tomcat-5.0.28.tar.gz     libexec     man            share  

第二步: 设置环境变量 我想到这的话,可能有人会问,为什么要设置环境变量。

提供一个网址,http://www.linuxidc.com/Linux/2009-12/23735.htm

上面说的比较详细: 总体来说就在运行tomact命令是能找到tomcat 的目录,知道它安装到哪了。  

下面设置一个两个环境变量CATALINA_HOME和CATALINA_BASE, 编辑~/.bashrc文件。

加入  

export CATALINA_BASE=/usr/local/jakarta-tomcat-5.0.28

export CATALINA_HOME=/usr/local/jakarta-tomcat-5.0.28

[root@tpwb local]# cd ~

[root@tpwb ~]# ls -a

.                  .bash_history     .bashrc     .gconfd         install.log.syslog ..                  .bash_logout      .cshrc      .gtkrc          .tcshrc anaconda-ks.cfg     .bash_profile     .gconf      install.log     .viminfo

[root@tpwb ~]# vi .bashrc

if [ -f /etc/bashrc ];

then . /etc/bashrc fi

export JAVA_HOME=/usr/java/j2sdk1.4.2_04

export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib

export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/bin

export CATALINA_BASE=/usr/local/jakarta-tomcat-5.0.28

export CATALINA_HOME=/usr/local/jakarta-tomcat-5.0.28  

vi命令用于编辑文本。wq保存退出. 想了解更详细的命令,可以查看上面推荐网址   如果想设置其他用户的环境变量,方法是一样的。在这里不在说了,我在“linux下安装JDK”文章里已经说的很详细了。   下面来验证一下变量设置是否生效   设置完环境变量最好重起一下,不然看不到效果。  

[root@tpwb tp]# reboot

Broadcast message from root (pts/0) (Fri Jan 19 16:51:26 2007): The system is going down for reboot NOW!

我们来查看一下

[root@tpwb ~]# echo $CATALINA_HOME /usr/local/jakarta-tomcat-5.0.28

[root@tpwb ~]# echo $CATALINA_BASE /usr/local/jakarta-tomcat-5.0.28 已经没问题了。

本篇文章来源于 Linux公社网站(www.linuxidc.com

原文链接:http://www.linuxidc.com/Linux/2009-12/23734.htm