﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-天外的星星</title><link>http://www.blogjava.net/leishengwei/</link><description /><language>zh-cn</language><lastBuildDate>Sun, 12 Apr 2026 06:06:46 GMT</lastBuildDate><pubDate>Sun, 12 Apr 2026 06:06:46 GMT</pubDate><ttl>60</ttl><item><title>JAVA集合类，容器类</title><link>http://www.blogjava.net/leishengwei/archive/2012/03/20/372246.html</link><dc:creator>天外的星星</dc:creator><author>天外的星星</author><pubDate>Tue, 20 Mar 2012 01:47:00 GMT</pubDate><guid>http://www.blogjava.net/leishengwei/archive/2012/03/20/372246.html</guid><wfw:comment>http://www.blogjava.net/leishengwei/comments/372246.html</wfw:comment><comments>http://www.blogjava.net/leishengwei/archive/2012/03/20/372246.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/leishengwei/comments/commentRss/372246.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/leishengwei/services/trackbacks/372246.html</trackback:ping><description><![CDATA[<p style="margin:0in;font-size:20.0pt"><font face="Calibri"><strong><br /></strong></font><br /></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">此文档据说是改编而来，然而笔者也付出了辛劳。<br />Java容器类Collection、List、ArrayList、Vector及map、HashTable、HashMap区别</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">Collection是List和Set两个接口的基接口 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">List在Collection之上增加了"有序" </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">Set在Collection之上增加了"唯一" </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">而ArrayList是实现List的类...所以他是有序的. </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">它里边存放的元素在排列上存在一定的先后顺序 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">而且ArrayList是采用数组存放元素 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">另一种List LinkedList采用的则是链表。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">Collection和Map接口之间的主要区别在于：Collection中存储了一组对象，而Map存储关键字/值对。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">在Map对象中，每一个关键字最多有一个关联的值。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">Map:不能包括两个相同的键，一个键最多能绑定一个值。null可以作为键，这样的键只有一个；可以有一个或多个键所对应的 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">值为null。当get()方法返回null值时，即可以表示Map中没有该键，也可以表示该键所对应的值为null。<span style="font-weight:bold;color:red">因此，在Map中不能由get()方法来判断Map中是否存在某个键，而应该用containsKey()方法来判断。</span> </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">继承Map的类有：HashMap，HashTable </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">HashMap</span>：Map的实现类，<span style="color:red">缺省情况下是非同步的</span>，可以通过Map Collections.synchronizedMap(Map m)来达到线程同步 </p>  <p style="margin:0in;font-size:10.5pt"><span style="font-weight:bold; font-family:Calibri;background:#FFFF99">HashTable</span><span style="font-family: Calibri;background:#FFFF99">：Dictionary的子类，</span><span style="font-family: 宋体;color:red;background:#FFFF99">缺省</span><span style="font-family:Calibri; color:red;background:#FFFF99">是线程同步的</span><span style="font-family:Calibri; background:#FFFF99">。不允许关键字或值为null</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">当元素的顺序很重要时选用<span style="font-weight:bold">TreeMap</span>，当元素不必以特定的顺序进行存储时，使用HashMap。<span style="font-weight:bold;color:red">Hashtable的使用不被推荐，因为HashMap提供了所有类似的功能，并且速度更快。当你需要在多线程环境下使用时，HashMap也可以转换为同步的。</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">为什么要使用集合类 </span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">当你事先不知道要存放数据的个数，或者你需要一种比数组下标存取机制更灵活的方法时，你就需要用到集合类。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">理解集合类 </span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">集合类存放于java.util包中。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">集合类存放的都是对象的引用，而非对象本身，出于表达上的便利，我们称集合中的对象就是指集合中对象的引用（reference)。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt;color:red"><span style="background:yellow;">集合类型主要有3种：</span><span style="font-weight:bold;background:yellow;">set(</span><span style="background:yellow;">集）、</span><span style="font-weight:bold;background:yellow;">list(</span><span style="background:yellow;">列表）和</span><span style="font-weight:bold;background:yellow;">map(</span><span style="background:yellow;">映射)。</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-size:10.5pt"><span style="font-weight:bold; font-family:Calibri">(1)集</span> <span style="font-family:宋体">（</span><span style="font-family:Calibri">Set</span><span style="font-family:宋体">）：口袋</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">集（set）是最简单的一种集合，它的对象不按特定方式排序，只是简单的把对象加入集合中，就像往口袋里放东西。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">对集中成员的访问和操作是通过集中对象的引用进行的，所以集中不能有重复对象。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">集也有多种变体，可以实现排序等功能，如TreeSet，它把对象添加到集中的操作将变为按照某种比较规则将其插入到有序的对象序列中。它实现的是SortedSet接口，也就是加入了对象比较的方法。通过对集中的对象迭代，我们可以得到一个升序的对象集合。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-size:10.5pt"><span style="font-weight:bold; font-family:Calibri">(2)列表</span> <span style="font-family:宋体">（</span><span style="font-family:Calibri">List</span><span style="font-family: 宋体">）：列表</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">列表的主要特征是其对象以线性方式存储，没有特定顺序，只有一个开头和一个结尾，当然，它与根本没有顺序的集是不同的。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">列表在数据结构中分别表现为：数组和向量、链表、堆栈、队列。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">关于实现列表的集合类，是我们日常工作中经常用到的，将在后边的笔记详细介绍。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-size:10.5pt"><span style="font-weight:bold; font-family:Calibri">(3)映射</span> <span style="font-family:宋体">（</span><span style="font-family:Calibri">Map</span><span style="font-family:宋体">）：键值对</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">映射与集或列表有明显区别，映射中每个项都是成对的。映射中存储的每个对象都有一个相关的关键字（Key）对象，关键字决定了对象在映射中的存储位置，检索对象时必须提供相应的关键字，就像在字典中查单词一样。关键字应该是唯一的。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">关键字本身并不能决定对象的存储位置，它需要对过一种<span style="font-weight:bold">散列(hashing)技术</span>来处理，产生一个被称作散列码(hash code)的整数值，散列码通常用作一个偏置量，该偏置量是相对于分配给映射的内存区域起始位置的，由此确定关键字/对象对的存储位置。理想情况下，散列处理应该产生给定范围内均匀分布的值，而且每个关键字应得到不同的散列码。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">集合类简介 </span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">java.util中共有13个类可用于管理集合对象，它们支持集、列表或映射等集合，以下是这些类的简单介绍</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri"><span style="font-weight:bold; font-size:16.0pt">集</span><span style="font-weight:bold;font-size:10.5pt">：</span> </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">HashSet</span>： 使用HashMap的一个集的实现。虽然集定义成无序，但必须存在某种方法能相当高效地找到一个对象。使用一个HashMap对象实现集的存储和检索操作是在固定时间内实现的. </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">TreeSet</span>： 在集中以升序对对象排序的集的实现。这意味着从一个TreeSet对象获得第一个迭代器将按升序提供对象。TreeSet类使用了一个TreeMap. </p>  <p style="margin:0in;font-family:Calibri"><span style="font-weight:bold; font-size:16.0pt">列表</span><span style="font-size:10.5pt">： </span></p>  <p style="margin:0in;font-size:10.5pt"><span style="font-weight:bold; font-family:Calibri">Vector</span><span style="font-family:Calibri">： 实现一个类似数组一样的表，自动增加容量来容纳你所需的元素。使用下标存储和检索对象就象在一个标准的数组中一样。你也可以用一个迭代器从一个Vector中检索对象。</span><span style="font-weight:bold;font-family:Calibri">Vector是唯一的同步容器类</span><span style="font-family:Calibri">??当两个或多个线程同时访问时也是性能良好的。（</span><span style="font-weight:bold;font-family:Calibri;color:red">同步</span><span style="font-weight:bold;font-family:宋体;color:red">的含义：</span><span style="font-weight:bold;font-family:Calibri;color:red">即同时只能一个进程访问，其他等待</span><span style="font-family:Calibri">） </span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">Stack:</span> 这个类从Vector派生而来，并且增加了方法实现栈??一种后进先出的存储结构。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">LinkedList</span>: 实现一个链表。由这个类定义的链表也可以像栈或队列一样被使用。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">ArrayList:</span> 实现一个数组，它的规模可变并且能像链表一样被访问。它提供的功能类似Vector类但不同步。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">映射： </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">HashTable</span>： 实现一个映象，所有的键必须非空。为了能高效的工作，定义键的类必须实现hashcode()方法和equal()方法。这个类是前面java实现的一个继承，并且通常能在实现映象的其他类中更好的使用。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">HashMap：</span> 实现一个映象，允许存储空对象，而且允许键是空（由于键必须是唯一的，当然只能有一个）。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">WeakHashMap：</span> 实现这样一个映象：通常如果一个键对一个对象而言不再被引用，键/对象对将被舍弃。这与HashMap形成对照，映象中的键维持键/对象对的生命周期，尽管使用映象的程序不再有对键的引用，并且因此不能检索对象。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">TreeMap</span>： 实现这样一个映象，对象是按键升序排列的。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">下图是集合类所实现的接口之间的关系：</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">Set和List都是由公共接口Collection扩展而来，所以它们都可以使用一个类型为Collection的变量来引用。这就意味着任何列表或集构成的集合都可以用这种方式引用，只有映射类除外（但也不是完全排除在外，因为可以从映射获得一个列表。）所以说，把一个列表或集传递给方法的标准途径是使用Collection类型的参数。</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">List接口</span> </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; List是有序的Collection，使用此接口能够精确的控制每个元素插入的位置。用户能够使用索引（元素在List中的位置，类似于数组下标）来访问List中的元素，这类似于Java的数组。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">和下面要提到的Set不同，List允许有相同的元素。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; 除了具有Collection接口必备的iterator()方法外，List还提供一个listIterator()方法，返回一个ListIterator接口，和标准的Iterator接口相比，ListIterator多了一些add()之类的方法，允许添加，删除，设定元素，还能向前或向后遍历。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; 实现List接口的常用类有LinkedList，ArrayList，Vector和Stack。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">ArrayList</span>类 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; ArrayList实现了可变大小的数组。它允许所有元素，包括null。ArrayList没有同步。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">size，isEmpty，get，set方法运行时间为常数。但是add方法开销为分摊的常数，添加n个元素需要O(n)的时间。其他的方法运行时间为线性。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; 每个ArrayList实例都有一个容量（<span style="font-weight: bold">Capacity</span>），即用于存储元素的数组的大小。这个容量可随着不断添加新元素而自动增加，但是增长算法并没有定义。<span style="font-weight:bold;color:red">ArrayList当需要插入大量元素时，在插入前可以调用ensureCapacity方法来增加ArrayList的容量以提高插入效率。</span> </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; 和LinkedList一样，ArrayList也是非同步的（unsynchronized）。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">Map接口</span> </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; 请注意，Map没有继承Collection接口，Map提供key到value的映射。一个Map中不能包含相同的key，每个key只能映射一个value。Map接口提供3种集合的视图，Map的内容可以被当作一组key集合，一组value集合，或者一组key-value映射。 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">HashMap</span>类 </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">&nbsp; HashMap和Hashtable类似，不同之处在于HashMap是非同步的，并且允许null，即null value和null key。，但是将HashMap视为Collection时（values()方法可返回Collection），其迭代子操作时间开销和HashMap的容量成比例。因此，<span style="font-weight:bold">如果迭代操作的性能相当重要的话，不要将HashMap的初始化容量设得过高，或者load factor过低。</span> </p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">----------------------------------------------------------------------------</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">1.</span><span style="font-weight:bold">--------------------&gt;</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">List是接口，List特性就是有序,会确保以一定的顺序保存元素.</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">ArrayList是它的实现类,是一个用数组实现的List.</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">Map是接口,Map特性就是根据一个对象查找对象.</p>  <p style="margin:0in;font-size:10.5pt"><span style="font-family:Calibri">HashMap是它的实现类,HashMap用hash表实现的Map,就是利用对象的hashcode(hashcode()是Object的方法)进行快速</span><span style="font-family:宋体">（</span><span style="font-family:Calibri">Hash</span><span style="font-family:宋体">）</span><span style="font-family:Calibri">散列查找.(关于散列查找,可以参看&lt;&lt;数据结构&gt;&gt;)</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">2.</span>--------------------&gt;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">一般情况下,如果没有必要,推荐代码只同List,Map接口打交道.</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">比如:List list = new ArrayList();</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">这样做的原因是list就相当于是一个泛型的实现,如果想改变list的类型,只需要:</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">List list = new LinkedList();//LinkedList也是List的实现类,也是ArrayList的兄弟类</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">这样,就不需要修改其它代码,这就是<span style="font-weight:bold">接口编程的优雅之处.</span></p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">另外的例子就是,在类的方法中,如下声明:</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">private void doMyAction(List list){}</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt">这样这个方法能处理所有实现了List接口的类,一定程度上实现了泛型函数.</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt"><span style="font-weight:bold">3.</span>---------------------&gt;</p>  <p style="margin:0in;font-family:Calibri;font-size:10.5pt;color:red">如果开发的时候觉得ArrayList,HashMap的性能不能满足你的需要,可以通过实现List,Map(或者Collection)来定制你的自定义类</p><img src ="http://www.blogjava.net/leishengwei/aggbug/372246.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/leishengwei/" target="_blank">天外的星星</a> 2012-03-20 09:47 <a href="http://www.blogjava.net/leishengwei/archive/2012/03/20/372246.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Windows下配置JAVA和Tomcat环境变量</title><link>http://www.blogjava.net/leishengwei/archive/2012/03/20/372242.html</link><dc:creator>天外的星星</dc:creator><author>天外的星星</author><pubDate>Tue, 20 Mar 2012 01:42:00 GMT</pubDate><guid>http://www.blogjava.net/leishengwei/archive/2012/03/20/372242.html</guid><wfw:comment>http://www.blogjava.net/leishengwei/comments/372242.html</wfw:comment><comments>http://www.blogjava.net/leishengwei/archive/2012/03/20/372242.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/leishengwei/comments/commentRss/372242.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/leishengwei/services/trackbacks/372242.html</trackback:ping><description><![CDATA[<ol type="1" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="1" style="margin-top: 0px; margin-bottom: 0px; vertical-align: middle; "><span style="font-weight: bold; font-family: 宋体; font-size: 10.5pt; ">关于环境变量：</span></li>  <ol type="1" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-size: 10.5pt; ">   <li value="1" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">（</span><span style="font-size: 10.5pt; ">Windows 7</span><span style="font-family: 宋体; font-size: 10.5pt; ">）右键点击桌面的计算机，选择属性，点击左侧的高级系统设置，打开系统属性设置框，点击最下面的环境变量，即可打开环境变量设置对话框。</span></li>  </ol>  <ol type="1" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-size: 10.5pt; ">   <li value="2" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">环境变量包括系统变量和用户变量，如果配置在用户变量，则该环境变量仅对当前用户生效，如果配置为系统变量，则对所有用户生效，其他应再无区别。</span></li>   <li style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family:宋体;font-size:10.5pt">环境变量里面，我们用两个比较特殊的环境变量，一个是</span><span style="font-size: 10.5pt; ">PATH</span><span style="font-family:宋体;font-size:10.5pt">，一个是</span><span style="font-size: 10.5pt; ">CLASSPATH</span><span style="font-family:宋体;font-size:10.5pt">，配置在</span><span style="font-size: 10.5pt; ">PATH</span><span style="font-family:宋体;font-size:10.5pt">里面的路径，可以直接在命令提示符下面执行路径对应的文件或文件夹下的</span><span style="font-size: 10.5pt; ">exe</span><span style="font-family:宋体;font-size:10.5pt">和</span><span style="font-size: 10.5pt; ">bat</span><span style="font-family:宋体;font-size:10.5pt">等命令进行运行，如：</span></li>  </ol> </ol>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:宋体">我们将你的</span><span style="font-family:&quot;Times New Roman&quot;">JDK</span><span style="font-family:宋体">目录（如</span><span style="font-family:&quot;Times New Roman&quot;">D:\JAVA\JDK1.7.0\bin</span><span style="font-family:宋体">）加入环境变量，则该变量下面有例如</span><span style="font-family:&quot;Times New Roman&quot;">java.exe ,javac.exe</span><span style="font-family:宋体">等文件。我们可以在命令提示符下面进行如</span><span style="font-family:&quot;Times New Roman&quot;">java,javac</span><span style="font-family:宋体">等命令。</span></p>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:宋体">另外一个</span><span style="font-family:&quot;Times New Roman&quot;">CLASSPATH</span><span style="font-family:宋体">，这里暂时不说。</span></p>  <ol type="1" style="margin-left: 0.75in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 宋体; font-size: 10.5pt; ">  <li value="4" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-size: 10.5pt; ">在环境变量配置里面引用环境变量可以用如下格式：</span></li> </ol>  <p style="margin:0in;margin-left:1.125in;font-size:10.5pt"><span style="font-family:Calibri">%</span><span style="font-family:宋体">变量名</span><span style="font-family:Calibri">%</span></p>  <ol type="1" style="margin-left: 0.75in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: Calibri; font-size: 10.5pt; ">  <li value="5" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: SimSun; font-size: 10.5pt; ">英文的句号即点（</span><span style="font-size: 10.5pt; ">.</span><span style="font-family: SimSun; font-size: 10.5pt; ">）表示任何当前路径。</span></li> </ol>  <ol type="1" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="2" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-weight: bold; font-size: 10.5pt; ">Java</span><span style="font-weight: bold; font-family: 宋体; font-size: 10.5pt; ">环境变量配置：</span></li>  <ol type="a" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-size: 10.5pt; ">   <li value="1" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">配置</span><span style="font-size: 10.5pt; ">JAVA_HOME</span><span style="font-family: 宋体; font-size: 10.5pt; ">（格式为变量名</span><span style="font-size: 10.5pt; ">=</span><span style="font-family: 宋体; font-size: 10.5pt; ">变量值</span><span style="font-size: 10.5pt; ">[</span><span style="font-family: 宋体; font-size: 10.5pt; ">示例值</span><span style="font-size: 10.5pt; ">]</span><span style="font-family: 宋体; font-size: 10.5pt; ">）：</span></li>  </ol> </ol>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;">JAVA_HOME = </span><span style="font-family:宋体">你的</span><span style="font-family:&quot;Times New Roman&quot;">JDK</span><span style="font-family:宋体">的目录</span><span style="font-family:&quot;Times New Roman&quot;">[D:\Java\jdk1.7.0]</span></p>  <ol type="a" style="margin-left: 0.75in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="2" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">配置</span><span style="font-size: 10.5pt; ">JRE_HOME</span><span style="font-family: 宋体; font-size: 10.5pt; ">（可选）</span></li> </ol>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;">JRE_HOME =&nbsp; </span><span style="font-family:宋体">你的</span><span style="font-family:&quot;Times New Roman&quot;">JRE</span><span style="font-family:宋体">的目录</span><span style="font-family:&quot;Times New Roman&quot;">[D:\Java\jdk1.7.0\jre]</span></p>  <ol type="a" style="margin-left: 0.75in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="3" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-size: 10.5pt; ">PATH</span><span style="font-family: 宋体; font-size: 10.5pt; ">配置：</span></li> </ol>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:宋体">在系统变量中查找</span><span style="font-family:&quot;Times New Roman&quot;">PATH</span><span style="font-family:宋体">变量，如果没有则新建，如果有的话，双击打开，在已有的变量值后面添加，各个变量配置值之间用英文的分号（</span><span style="font-family:&quot;Times New Roman&quot;">;</span><span style="font-family:宋体">）隔开，需要添加以下几个变量值：</span></p>  <p style="margin:0in;margin-left:.75in;font-family:&quot;Times New Roman&quot;; font-size:10.5pt">PATH = %JAVA_HOME%\bin</p>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;">PATH = %JRE_HOME%\bin&nbsp; (</span><span style="font-family:宋体">可选</span><span style="font-family:&quot;Times New Roman&quot;">)</span></p>  <ol type="a" style="margin-left: 0.75in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="4" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">配置</span><span style="font-size: 10.5pt; ">CLASSPATH</span><span style="font-family: 宋体; font-size: 10.5pt; ">：</span></li> </ol>  <p style="margin:0in;margin-left:.75in;font-family:&quot;Times New Roman&quot;; font-size:10.5pt">CLASSPATH = D:\Java\jdk1.7.0\lib\dt.jar</p>  <ol type="1" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="3" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-weight: bold; font-size: 10.5pt; ">TOMCAT</span><span style="font-weight: bold; font-family: 宋体; font-size: 10.5pt; ">的配置：</span></li>  <ol type="a" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-size: 10.5pt; ">   <li value="1" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">配置</span><span style="font-size: 10.5pt; ">CATALINA_HOME</span><span style="font-family: 宋体; font-size: 10.5pt; ">：</span></li>  </ol> </ol>  <p style="margin:0in;margin-left:.75in;font-size:10.5pt"><span style="font-family:&quot;Times New Roman&quot;">CATALINA_HOME = </span><span style="font-family:宋体">你的</span><span style="font-family:&quot;Times New Roman&quot;">TOMCAT</span><span style="font-family:宋体">的目录</span><span style="font-family:&quot;Times New Roman&quot;">[D:\Develop\apache-tomcat-7.0.2]</span></p>  <ol type="a" style="margin-left: 0.75in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="2" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: 宋体; font-size: 10.5pt; ">配置</span><span style="font-size: 10.5pt; ">PATH</span><span style="font-family: 宋体; font-size: 10.5pt; ">：</span></li> </ol>  <p style="margin:0in;margin-left:.75in;font-family:&quot;Times New Roman&quot;; font-size:10.5pt">PATH=%CATALINA_HOME%\bin</p>  <ol type="1" style="margin-left: 0.375in; direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in; font-family: 'Times New Roman'; font-size: 10.5pt; ">  <li value="4" style="margin-top:0;margin-bottom:0;vertical-align:middle"><span style="font-family: SimSun; font-size: 10.5pt; ">测试</span><span style="font-size: 10.5pt; ">:</span></li> </ol>  <p style="margin:0in;margin-left:.375in;font-size:10.5pt"><span style="font-family:宋体">开始&#8221;－</span><span style="font-family:&quot;Times New Roman&quot;">&gt;;</span><span style="font-family:宋体">&#8220;运行&#8221;，键入&#8220;</span><span style="font-family:&quot;Times New Roman&quot;">cmd</span><span style="font-family:宋体">&#8221;（这里做测试）；</span> </p>  <p style="margin:0in;margin-left:.375in;font-size:10.5pt"><span style="font-family:宋体">可以键入命令&#8220;</span><span style="font-family:&quot;Times New Roman&quot;">java -version</span><span style="font-family:宋体">&#8221;，&#8220;</span><span style="font-family:&quot;Times New Roman&quot;">java</span><span style="font-family:宋体">&#8221;，&#8220;</span><span style="font-family:&quot;Times New Roman&quot;">javac</span><span style="font-family:宋体">&#8221;几个命令，出现画面，说明环境变量配置成功；</span></p><img src ="http://www.blogjava.net/leishengwei/aggbug/372242.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/leishengwei/" target="_blank">天外的星星</a> 2012-03-20 09:42 <a href="http://www.blogjava.net/leishengwei/archive/2012/03/20/372242.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>