﻿<?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-&lt;center&gt;&lt;h1&gt;&lt;strong&gt;&lt;font color="#8088B7"&gt;&lt;em&gt;在幸福中痛苦的挣扎&lt;/em&gt;&lt;/font&gt;&lt;/strong&gt;&lt;/h1&gt;&lt;/center&gt;</title><link>http://www.blogjava.net/soft/</link><description>&lt;center&gt;&lt;font color="black" size="3"&gt;专注于效率  专注于价值&lt;/font&gt;&lt;br&gt;&amp;nbsp;&lt;br&gt;  
&lt;font size="5"&gt;&lt;b&gt;书法.JAVA BLOG&lt;/b&gt;&lt;/font&gt;&lt;/center&gt;</description><language>zh-cn</language><lastBuildDate>Tue, 28 Apr 2026 18:56:29 GMT</lastBuildDate><pubDate>Tue, 28 Apr 2026 18:56:29 GMT</pubDate><ttl>60</ttl><item><title>Tomcat5.5数据库连接池的配置</title><link>http://www.blogjava.net/soft/archive/2006/11/28/83948.html</link><dc:creator>书法</dc:creator><author>书法</author><pubDate>Mon, 27 Nov 2006 19:25:00 GMT</pubDate><guid>http://www.blogjava.net/soft/archive/2006/11/28/83948.html</guid><wfw:comment>http://www.blogjava.net/soft/comments/83948.html</wfw:comment><comments>http://www.blogjava.net/soft/archive/2006/11/28/83948.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/soft/comments/commentRss/83948.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/soft/services/trackbacks/83948.html</trackback:ping><description><![CDATA[刚把5.0的配置搞定，换了5.5版本就不一样了，试了半天结合5.0的配置经验，终于搞定了，还算有成就感^_^。

第一步：把数据库驱动拷贝到Tomcat安装目录的/common/lib下和你自己网站的/WEB-INF/lib下（我用的mysql，其他一样）；
第二步：以admin身份进入Tomcat管理界面配置用户名、密码、连接数目...
　　之后生成的Server.xml文件如下（如果不想配置，你也可以直接修改后使用）


    
<!-- Example Server Configuration File -->
<!-- Note that component elements are nested corresponding to their
     parent-child relationships with each other -->

<!-- A "Server" is a singleton element that represents the entire JVM,
     which may contain one or more "Service" instances.  The Server
     listens for a shutdown command on the indicated port.

     Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" or "Loggers" at this level.
 -->

<Server port="8005" shutdown="SHUTDOWN">

  <!-- Comment these entries out to disable JMX MBeans support used for the 
       administration web application -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.storeconfig.StoreConfigLifecycleListener"/>

  <!-- Global JNDI resources -->
  <GlobalNamingResources>

    <!-- Test entry for demonstration purposes -->
    <Environment name="simpleValue" type="java.lang.Integer" value="30"/>

    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users -->
   
<Resource
      name="jdbc/mysql"
      type="javax.sql.DataSource"
      password="********"
      driverClassName="org.gjt.mm.mysql.Driver"
      maxIdle="2"
      maxWait="1000"
      username="root"
      url="jdbc:mysql://127.0.0.1/test"
      maxActive="4"/>
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" (and therefore the web applications visible
       within that Container).  Normally, that Container is an "Engine",
       but this is not required.

       Note:  A "Service" is not itself a "Container", so you may not
       define subcomponents such as "Valves" or "Loggers" at this level.
   -->

  <!-- Define the Tomcat Stand-Alone Service -->
  <Service name="Catalina">

    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned.  Each Connector passes requests on to the
         associated "Container" (normally an Engine) for processing.

         By default, a non-SSL HTTP/1.1 Connector is established on port 8080.
         You can also enable an SSL HTTP/1.1 Connector on port 8443 by
         following the instructions below and uncommenting the second Connector
         entry.  SSL support requires the following steps (see the SSL Config
         HOWTO in the Tomcat 5 documentation bundle for more detailed
         instructions):
         * If your JDK version 1.3 or prior, download and install JSSE 1.0.2 or
           later, and put the JAR files into "$JAVA_HOME/jre/lib/ext".
         * Execute:
             %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA (Windows)
             $JAVA_HOME/bin/keytool -genkey -alias tomcat -keyalg RSA  (Unix)
           with a password value of "changeit" for both the certificate and
           the keystore itself.

         By default, DNS lookups are enabled when a web application calls
         request.getRemoteHost().  This can have an adverse impact on
         performance, so you can disable it by setting the
         "enableLookups" attribute to "false".  When DNS lookups are disabled,
         request.getRemoteHost() will return the String version of the
         IP address of the remote client.
    -->

    <!-- Define a non-SSL HTTP/1.1 Connector on port 8080 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />
    <!-- Note : To disable connection timeouts, set connectionTimeout value
     to 0 -->
	
	<!-- Note : To use gzip compression you could set the following properties :
	
			   compression="on" 
			   compressionMinSize="2048" 
			   noCompressionUserAgents="gozilla, traviata" 
			   compressableMimeType="text/html,text/xml"
	-->

    <!-- Define a SSL HTTP/1.1 Connector on port 8443 -->
    <!--
    <Connector port="8443" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" disableUploadTimeout="true"
               acceptCount="100" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" 
               enableLookups="false" redirectPort="8443" protocol="AJP/1.3" />

    <!-- Define a Proxied HTTP/1.1 Connector on port 8082 -->
    <!-- See proxy documentation for more information about using this. -->
    <!--
    <Connector port="8082" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" acceptCount="100" connectionTimeout="20000"
               proxyPort="80" disableUploadTimeout="true" />
    -->

    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host). -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Standalone" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
         
    <!-- Define the top level container in our container hierarchy -->
    <Engine name="Catalina" defaultHost="localhost">

      <!-- The request dumper valve dumps useful debugging information about
           the request headers and cookies that were received, and the response
           headers and cookies that were sent, for all requests received by
           this instance of Tomcat.  If you care only about requests to a
           particular virtual host, or a particular application, nest this
           element inside the corresponding <Host> or <Context> entry instead.

           For a similar mechanism that is portable to all Servlet 2.4
           containers, check out the "RequestDumperFilter" Filter in the
           example application (the source for this filter may be found in
           "$CATALINA_HOME/webapps/examples/WEB-INF/classes/filters").

           Request dumping is disabled by default.  Uncomment the following
           element to enable it. -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->

      <!-- Because this Realm is here, an instance will be shared globally -->

      <!-- This Realm uses the UserDatabase configured in the global JNDI
           resources under the key "UserDatabase".  Any edits
           that are performed against this UserDatabase are immediately
           available for use by the Realm.  -->
      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
             resourceName="UserDatabase"/>

      <!-- Comment out the old realm but leave here for now in case we
           need to go back quickly -->
      <!--
      <Realm className="org.apache.catalina.realm.MemoryRealm" />
      -->

      <!-- Replace the above Realm with one of the following to get a Realm
           stored in a database and accessed via JDBC -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm"
             driverName="org.gjt.mm.mysql.Driver"
          connectionURL="jdbc:mysql://localhost/authority"
         connectionName="test" connectionPassword="test"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm"
             driverName="oracle.jdbc.driver.OracleDriver"
          connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
         connectionName="scott" connectionPassword="tiger"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!--
      <Realm  className="org.apache.catalina.realm.JDBCRealm"
             driverName="sun.jdbc.odbc.JdbcOdbcDriver"
          connectionURL="jdbc:odbc:CATALINA"
              userTable="users" userNameCol="user_name" userCredCol="user_pass"
          userRoleTable="user_roles" roleNameCol="role_name" />
      -->

      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost" appBase="webapps"
       unpackWARs="true" autoDeploy="true"
       xmlValidation="false" xmlNamespaceAware="false">

        <!-- Defines a cluster for this node,
             By defining this element, means that every manager will be changed.
             So when running a cluster, only make sure that you have webapps in there
             that need to be clustered and remove the other ones.
             A cluster has the following parameters:

             className = the fully qualified name of the cluster class

             name = a descriptive name for your cluster, can be anything

             mcastAddr = the multicast address, has to be the same for all the nodes

             mcastPort = the multicast port, has to be the same for all the nodes
             
             mcastBindAddr = bind the multicast socket to a specific address
             
             mcastTTL = the multicast TTL if you want to limit your broadcast
             
             mcastSoTimeout = the multicast readtimeout 

             mcastFrequency = the number of milliseconds in between sending a "I'm alive" heartbeat

             mcastDropTime = the number a milliseconds before a node is considered "dead" if no heartbeat is received

             tcpThreadCount = the number of threads to handle incoming replication requests, optimal would be the same amount of threads as nodes 

             tcpListenAddress = the listen address (bind address) for TCP cluster request on this host, 
                                in case of multiple ethernet cards.
                                auto means that address becomes
                                InetAddress.getLocalHost().getHostAddress()

             tcpListenPort = the tcp listen port

             tcpSelectorTimeout = the timeout (ms) for the Selector.select() method in case the OS
                                  has a wakup bug in java.nio. Set to 0 for no timeout

             printToScreen = true means that managers will also print to std.out

             expireSessionsOnShutdown = true means that 

             useDirtyFlag = true means that we only replicate a session after setAttribute,removeAttribute has been called.
                            false means to replicate the session after each request.
                            false means that replication would work for the following piece of code: (only for SimpleTcpReplicationManager)
                            <%
                            HashMap map = (HashMap)session.getAttribute("map");
                            map.put("key","value");
                            %>
             replicationMode = can be either 'pooled', 'synchronous' or 'asynchronous'.
                               * Pooled means that the replication happens using several sockets in a synchronous way. Ie, the data gets replicated, then the request return. This is the same as the 'synchronous' setting except it uses a pool of sockets, hence it is multithreaded. This is the fastest and safest configuration. To use this, also increase the nr of tcp threads that you have dealing with replication.
                               * Synchronous means that the thread that executes the request, is also the
                               thread the replicates the data to the other nodes, and will not return until all
                               nodes have received the information.
                               * Asynchronous means that there is a specific 'sender' thread for each cluster node,
                               so the request thread will queue the replication request into a "smart" queue,
                               and then return to the client.
                               The "smart" queue is a queue where when a session is added to the queue, and the same session
                               already exists in the queue from a previous request, that session will be replaced
                               in the queue instead of replicating two requests. This almost never happens, unless there is a 
                               large network delay.
        -->             
        <!--
            When configuring for clustering, you also add in a valve to catch all the requests
            coming in, at the end of the request, the session may or may not be replicated.
            A session is replicated if and only if all the conditions are met:
            1. useDirtyFlag is true or setAttribute or removeAttribute has been called AND
            2. a session exists (has been created)
            3. the request is not trapped by the "filter" attribute

            The filter attribute is to filter out requests that could not modify the session,
            hence we don't replicate the session after the end of this request.
            The filter is negative, ie, anything you put in the filter, you mean to filter out,
            ie, no replication will be done on requests that match one of the filters.
            The filter attribute is delimited by ;, so you can't escape out ; even if you wanted to.

            filter=".*\.gif;.*\.js;" means that we will not replicate the session after requests with the URI
            ending with .gif and .js are intercepted.
            
            The deployer element can be used to deploy apps cluster wide.
            Currently the deployment only deploys/undeploys to working members in the cluster
            so no WARs are copied upons startup of a broken node.
            The deployer watches a directory (watchDir) for WAR files when watchEnabled="true"
            When a new war file is added the war gets deployed to the local instance,
            and then deployed to the other instances in the cluster.
            When a war file is deleted from the watchDir the war is undeployed locally 
            and cluster wide
        -->
        
        <!--
        <Cluster className="org.apache.catalina.cluster.tcp.SimpleTcpCluster"
                 managerClassName="org.apache.catalina.cluster.session.DeltaManager"
                 expireSessionsOnShutdown="false"
                 useDirtyFlag="true"
                 notifyListenersOnReplication="true">

            <Membership 
                className="org.apache.catalina.cluster.mcast.McastService"
                mcastAddr="228.0.0.4"
                mcastPort="45564"
                mcastFrequency="500"
                mcastDropTime="3000"/>

            <Receiver 
                className="org.apache.catalina.cluster.tcp.ReplicationListener"
                tcpListenAddress="auto"
                tcpListenPort="4001"
                tcpSelectorTimeout="100"
                tcpThreadCount="6"/>

            <Sender
                className="org.apache.catalina.cluster.tcp.ReplicationTransmitter"
                replicationMode="pooled"
                ackTimeout="15000"/>

            <Valve className="org.apache.catalina.cluster.tcp.ReplicationValve"
                   filter=".*\.gif;.*\.js;.*\.jpg;.*\.png;.*\.htm;.*\.html;.*\.css;.*\.txt;"/>
                   
            <Deployer className="org.apache.catalina.cluster.deploy.FarmWarDeployer"
                      tempDir="/tmp/war-temp/"
                      deployDir="/tmp/war-deploy/"
                      watchDir="/tmp/war-listen/"
                      watchEnabled="false"/>
        </Cluster>
        -->        



        <!-- Normally, users must authenticate themselves to each web app
             individually.  Uncomment the following entry if you would like
             a user to be authenticated the first time they encounter a
             resource protected by a security constraint, and then have that
             user identity maintained across *all* web applications contained
             in this virtual host. -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all requests for this virtual host.  By
             default, log files are created in the "logs" directory relative to
             $CATALINA_HOME.  If you wish, you can specify a different
             directory with the "directory" attribute.  Specify either a relative
             (to $CATALINA_HOME) or absolute path to the desired directory.
        -->
        <!--
        <Valve className="org.apache.catalina.valves.AccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
        -->

        <!-- Access log processes all requests for this virtual host.  By
             default, log files are created in the "logs" directory relative to
             $CATALINA_HOME.  If you wish, you can specify a different
             directory with the "directory" attribute.  Specify either a relative
             (to $CATALINA_HOME) or absolute path to the desired directory.
             This access log implementation is optimized for maximum performance,
             but is hardcoded to support only the "common" and "combined" patterns.
        -->
        <!--
        <Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
        -->
        <!-- Access log processes all requests for this virtual host.  By
             default, log files are created in the "logs" directory relative to
             $CATALINA_HOME.  If you wish, you can specify a different
             directory with the "directory" attribute.  Specify either a relative
             (to $CATALINA_HOME) or absolute path to the desired directory.
             This access log implementation is optimized for maximum performance,
             but is hardcoded to support only the "common" and "combined" patterns.

             This valve use NIO direct Byte Buffer to asynchornously store the
             log.
        -->
        <!--
        <Valve className="org.apache.catalina.valves.ByteBufferAccessLogValve"
                 directory="logs"  prefix="localhost_access_log." suffix=".txt"
                 pattern="common" resolveHosts="false"/>
        -->

      </Host>

    </Engine>

  </Service>

</Server>









第三步：在Tomcat/conf/Catalina/localhost目录下建立一个和你网站文件夹名字一样的XML文件。
例如：myweb.xml。内容如下：
<?xml version="1.0" encoding="UTF-8"?>
<Context>
 <Resource
      name="jdbc/mysql"
      type="javax.sql.DataSource"
      password="********"
      driverClassName="org.gjt.mm.mysql.Driver"
      maxIdle="2"
      maxWait="1000"
      username="root"
      url="jdbc:mysql://127.0.0.1/test"
      maxActive="4"/>
</Context>
注：这一步非常重要,如果没有这步就会出错,会出现org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'错误。
最后，在你自己网站的/WEB-INF/web.xml文件中，添加以下代码：
<resource-ref>
    <description>DB Connection</description>
    <res-ref-name>jdbc/mysql</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
</resource-ref>

OK。配置全部完成。现在你可以写代码测试这个数据库连接池了。如：
DataSource ds = null;
InitialContext ctx=new InitialContext();
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
Connection conn = ds.getConnection();
　　数据库连接对象得到了。
<img src ="http://www.blogjava.net/soft/aggbug/83948.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/soft/" target="_blank">书法</a> 2006-11-28 03:25 <a href="http://www.blogjava.net/soft/archive/2006/11/28/83948.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql 常用操作命令</title><link>http://www.blogjava.net/soft/archive/2006/11/24/psoft.html</link><dc:creator>书法</dc:creator><author>书法</author><pubDate>Fri, 24 Nov 2006 09:41:00 GMT</pubDate><guid>http://www.blogjava.net/soft/archive/2006/11/24/psoft.html</guid><wfw:comment>http://www.blogjava.net/soft/comments/83328.html</wfw:comment><comments>http://www.blogjava.net/soft/archive/2006/11/24/psoft.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/soft/comments/commentRss/83328.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/soft/services/trackbacks/83328.html</trackback:ping><description><![CDATA[
		<p>
				<font size="2">有些时候我们不得不去用命令行操作mysql数据库,下面是笔者总结的常见操作命令:<br /><br />1.连接 <br />  命令:  mysql -h主机地址 -u用户名 -p密码<br />  本地:连接   cmd进入mysql/bin之后, 输入mysql -uroot -p然后回车 会提示你输入密码 接着回车即可(如果密码为空);<br />  远程连接:假设远程主机的IP为：222.222.212.212，用户名为root,密码为abcdef。则键入以下命令：<br />     mysql -h222.222.212.212  -uroot  -pabcdef<br /><br />2.对数据库和表的操作<br />   <br />   查看用户拥有权限的数据库 :      show databases;(注意分号)<br /> <br />   创建数据库test:  create database testdb;<br /><br />   切换到testdb数据库:       use testdb;<br /><br />   删除数据库testdb: drop database testdb;<br /><br />   查看当前数据库中有权限的表: show tables;</font>
		</p>
		<p>
				<font size="2">   创建表s_position,department,,depart_pos,testtable:<br />     create table s_position<br />     (<br />         id int not null auto_increment,<br />         name varchar(20) not null default  '经理',          #设定默认值<br />         description varchar(100),<br />         primary key PK_positon (id)                            #设定主键<br />     );     <br />     create table department<br />     (<br />         id int not null auto_increment,<br />         name varchar(20) not null default '系统部',          #设定默认值<br />         description varchar(100),<br />         primary key PK_department (id)                        #设定主键<br />     );<br />     create table depart_pos<br />     (<br />         department_id int not null,<br />         position_id int not null,<br />         primary key PK_depart_pos (department_id,position_id)  #设定复和主键<br />     );<br />     create table testtable<br />     (<br />         id int not null auto_increment primary key,     #设定主键<br />         name varchar(20) not null default '无名氏',  #设定默认值<br />         department_id int not null,<br />         position_id int not null,<br />         unique (department_id,position_id)              #设定唯一值<br />     );<br /><br />   查看表testtable的结构:   desc testtable;</font>
		</p>
		<p>
				<font size="2">   删除表testtable:     <br />        drop table testtable;       <br /><br />  修改表结构 操作数据(增,删,改,查)<br />   .....(同sql语句,略)<br /><br /> 3. 备份和恢复 <br />   对数据的备份和恢复命令,在网上有许多种版本,经笔者亲身测验,下面的命令是可行方法之一:<br />   <br />    备份数据库testdb:  <br />    本地:mysqldump -uroot  -pabcdef testdb&gt;e:testdb.sql <br />    远程:mysqldump -h222.222.212.212 -uroot  -pabcdef testdb&gt;e:testdb.sql <br />   这里假设数据库的用户名和密码分别是root和abcdef, 导出到额盘根目录下,得到的testdb.sql是一个sql脚本，不包括建库的语句，所以你需要手工创建数据库下次才可以导入 恢复数据库testdb;<br />      <br />     恢复数据库testdb:      首先 需要创建一个空库testdb(原因如上);<br />     命令:   <br />     本地:mysql -uroot -pabcdef  testdb&lt;e:testdb.sql    <br />     远程:mysql -h222.222.212.212  -uroot -pabcdef  testdb&lt;e:testdb.sql    <br />     后面e:testdb.db代表本地sql文件路径,如果mysql安装在本地可以把sql文件考到mysql/bin的安装目录下,就不用写路径了.<br /><br /><br />注:在网上有些朋友说,mysql的安装目录必须为默认目录(即c:/mysql),否则会出问题,笔者也测验了一下在安装d盘的效果,结果暂时没有发现什么问题.,这说明有时候命令执行异常可能和安装目录无关.^_^</font>
		</p>
<img src ="http://www.blogjava.net/soft/aggbug/83328.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/soft/" target="_blank">书法</a> 2006-11-24 17:41 <a href="http://www.blogjava.net/soft/archive/2006/11/24/psoft.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>图片编辑器的实现--基于JAVA技术</title><link>http://www.blogjava.net/soft/archive/2006/11/21/82618.html</link><dc:creator>书法</dc:creator><author>书法</author><pubDate>Tue, 21 Nov 2006 14:08:00 GMT</pubDate><guid>http://www.blogjava.net/soft/archive/2006/11/21/82618.html</guid><wfw:comment>http://www.blogjava.net/soft/comments/82618.html</wfw:comment><comments>http://www.blogjava.net/soft/archive/2006/11/21/82618.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.blogjava.net/soft/comments/commentRss/82618.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/soft/services/trackbacks/82618.html</trackback:ping><description><![CDATA[		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt" align="left">
				<font size="2">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">一、</span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">技术概述</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 10.5pt; mso-char-indent-count: 1.0">
				<font size="2">
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">完全可以出色的实现多媒体的编辑与处理，包括图象的处理技术（</span>
						<span lang="EN-US">JGraph</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）、动画技术（</span>
						<span lang="EN-US">JFlash</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）、声音视频技术（</span>
						<span lang="EN-US">JMF</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）等等；</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 10.5pt; mso-char-indent-count: 1.0">
				<font size="2">
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">对图象处理进行了很好的支持，通过</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">提供的类，我们完全可以对图象进行各种常见的操作和变换；</span> </font>
				<font face="宋体">
						<font size="2">    </font>
						<span lang="EN-US">
								<br />
								<font size="2">      <span style="mso-list: Ignore">1、</span></font>
						</span>
						<span lang="EN-US">
								<font size="2">java图形图象处理所用到的相关类与接口：</font>
						</span>
				</font>
				<font size="2">   </font>
				<span lang="EN-US">
						<br />
						<font size="2">             </font>
						<font face="宋体">
								<font size="2">java.awt.color、java.awt.grahpics、java.awt.image、          <br />      java.awt.image.bufferedimage、<span style="mso-bidi-font-weight: bold">java.awt.image.LookupOp</span>、</font>
								<font size="2">
										<span style="mso-bidi-font-weight: bold">     <br />      java.awt.image.ConvolveOp</span>、<span style="mso-bidi-font-weight: bold">java.awt.image.AffineTransformOp</span>、<br />      bufferedimageop接口及其实现类等；</font>
						</font>
						<br />
				</span>
				<br />
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level2 lfo1; tab-stops: list 36.0pt">
				<font size="2">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">2、<span style="FONT: 7pt 'Times New Roman'">  </span></span>
						</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图形图象处理可以完成的功能：</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 45pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图象文件的打开（浏览）与保存（支持</span>
						<span lang="EN-US">jpg</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
						<span lang="EN-US">jpeg</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
						<span lang="EN-US">gif</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、</span>
						<span lang="EN-US">png</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等）、放大镜操作、旋转与镜像操作、反色和其他反色、黑白色阈值处理、亮度调整、缩放显示、边缘化、图形的锐化和钝化、其它功能等；</span>
						<span lang="EN-US">.</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 36pt; TEXT-INDENT: -18pt; mso-list: l0 level2 lfo1; tab-stops: list 36.0pt">
				<font size="2">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">3、<span style="FONT: 7pt 'Times New Roman'">  </span></span>
						</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">图形图象处理应用范围及限制：</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 47.25pt; mso-char-indent-count: 4.5">
				<font size="2">
						<span lang="EN-US">……………….<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /?><o:p></o:p></span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">
								<o:p> </o:p>
						</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">
								<o:p> </o:p>
						</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt">
				<font size="2">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">二、</span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实例演示介绍</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span lang="EN-US">c/s<span style="mso-spacerun: yes">  </span>Demo<span style="mso-spacerun: yes">  </span></span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">（<a href="http://www.blogjava.net/Files/soft/javaDrawer.rar">下载</a></span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">略</span>
						<span lang="EN-US">….</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">
								<o:p> </o:p>
						</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<span lang="EN-US">
						<font size="2">
								<o:p> </o:p>
						</font>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt; TEXT-INDENT: -21pt; mso-list: l0 level1 lfo1; tab-stops: list 21.0pt">
				<font size="2">
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">三、</span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关于使用</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</span>
						<span lang="EN-US">.net</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">技术实现图片编辑的分析与比较</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 21pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">关于</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">与</span>
						<span lang="EN-US">.net</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的争论从来没有停止过。</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span lang="EN-US">
								<span style="mso-spacerun: yes">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开放性是</span>
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">生命力的源泉，它不属于一个单独的公司，尽管</span>
						<span lang="EN-US">Sun</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在其中起着关键性的作用。众多世界级的公司，例如</span>
						<span lang="EN-US">IBM</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">、甲骨文、</span>
						<span lang="EN-US">BEA</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等等，都对</span>
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">都给予完全的支持，正是这样，</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的存在并继续产生一系列不平凡的影响是无庸置疑的；</span>
				</font>
				<font size="2">
						<span lang="EN-US">    <br />   <span style="mso-spacerun: yes">  </span></span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">出自微软的</span>
						<span lang="EN-US">.NET</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">最大的特点就是容易上手。花上两三个月时间，你就可以像模像样地当软件工程师了。相比之下，</span>
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">就不那么容易。而且，从软件技术的深度来看，</span>
						<span lang="EN-US">.NET</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">之中有没有分布式事务处理，这个问题仍然被许多资深的软件人员所质疑</span>
						<span lang="EN-US">….</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">不过，是同意</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">中的开发框架模式及诸多优秀开源组件更有价值，还是要更注重</span>
						<span lang="EN-US">.net</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的开发效率，这要根据企业以及项目自身来抉择，如果对于一个有着深厚的开发积累或者打算在相当一段时间长期使用的项目来说，没有采用</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开发平台的确是一个不太合理的事情，因为从长期看来，新的平台系统的混合使用必然会造成一些产品的不同平台的重复开发，而另一方面因为</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">独有的设计模式框架，会让一个</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">程序的后期维护变得相当简单容易，由此看来，它的开发成本并不一定会比其它语言的开发费用要高。</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">此前，</span>
						<span lang="EN-US">Jupitor</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">公司发布的一个报告显示，</span>
						<span lang="EN-US">62%</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的中小企业已经采用了</span>
						<span lang="EN-US">.NET</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">，而</span>
						<span lang="EN-US">36%</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的企业则采用基于</span>
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的</span>
						<span lang="EN-US">IBM   WebSphere</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">等服务平台。包括微软公司开发业务的负责人约翰·蒙哥马利也曾经表示：“</span>
						<span lang="EN-US">Java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">未来将会变成底层的编程框架，没有人可以通过它赚钱，它将会变成一个普通商品。”按照他的预测，明天的</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">或许就相当于今天的</span>
						<span lang="EN-US">C</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">；</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt">
				<font size="2">
						<span lang="EN-US">
								<span style="mso-spacerun: yes">    </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">在图形图片的处理领域内，有许多种不同的编程方式，就</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">技术而言，可以直接调用</span>
						<span lang="EN-US">java api</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">实现，同时在</span>
						<span lang="EN-US">java </span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">开源社区也有不少开源的组件，从效率上考虑，显然后者是一种更好的选择，并且相信在</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">领域内以后一定会有更多更优秀的开放性源码出现，这就是</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的活力</span>
						<span lang="EN-US">java</span>
				</font>
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的优势；<br /></span>
						<span lang="EN-US" style="mso-fareast-font-family: 'Times New Roman'">
								<span style="mso-list: Ignore">四、</span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">设想</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -42pt; mso-char-indent-count: -4.0">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方案</span>
						<span lang="EN-US">1</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：</span>
						<?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" /?>
						<st1:city>
								<st1:place>
										<span lang="EN-US">Ajax</span>
								</st1:place>
						</st1:city>
						<span lang="EN-US">+java </span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -10.5pt; mso-char-indent-count: -1.0; mso-para-margin-left: 3.0gd">
				<font size="2">
						<span lang="EN-US">
								<span style="mso-spacerun: yes"> </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">理由：充分利用</span>
						<span lang="EN-US">Ajax</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">胖客户端、无刷新加载提交数据及异步通信的特征，构造出</span>
						<span lang="EN-US">Internet</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">上极速处理图片及照片的体验平台，从而大大减少用户等待页面刷新的烦恼，使客户在充分享受上网的乐趣的同时对公司的产品也留下更为深刻的印象。</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -10.5pt; mso-char-indent-count: -1.0; mso-para-margin-left: 3.0gd">
				<font size="2">
						<span lang="EN-US">
								<span style="mso-spacerun: yes">  </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">优点：继承</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平台产品系统无关性、安全性、易维护升级、开放性等所有优点；</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: -42pt; mso-char-indent-count: -4.0">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">方案</span>
						<span lang="EN-US">2</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">：多语言平台开发模式</span>
						<span lang="EN-US">
								<span style="mso-spacerun: yes">  </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">以</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">平台实现在线编辑图片的功能而以其它语言平台（如</span>
						<span lang="EN-US">.net+GAI</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">）实现本地图片处理功能</span>
						<span lang="EN-US">
								<span style="mso-spacerun: yes">  </span>
						</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; mso-para-margin-left: 4.0gd">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">理由：语言本身无所谓好不好，它只是一个工具，它们都是为产品服务的，而产品又是为客户服务的，所以采用什么平台来开发产品最终是用户说了算，</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的出现本身就是基于</span>
						<span lang="EN-US">Internet</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">的，因此</span>
						<span lang="EN-US">B/S</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">模式下采用</span>
						<span lang="EN-US">java</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">技术，而以其它语言开发用户桌面应用程序，扬长避短，不但可以有效减小风险，而且产品开发周期也会快很多。</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; mso-para-margin-left: 4.0gd">
				<font size="2">
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">优点：风险小，效率高。</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; mso-para-margin-left: 4.0gd">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">
								<font size="2">                                                               </font>
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; mso-para-margin-left: 4.0gd">
				<span lang="EN-US">
						<span style="mso-spacerun: yes">
								<font size="2">                                                       </font>
						</span>
				</span>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; TEXT-INDENT: 288.75pt; mso-char-indent-count: 27.5; mso-para-margin-left: 4.0gd">
				<font size="2">
						<span lang="EN-US">
								<span style="mso-spacerun: yes">                                                               copyright@  </span>
						</span>
						<span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">彭书法</span>
				</font>
		</p>
		<p class="MsoNormal" style="MARGIN: 0cm 0cm 0pt 42pt; mso-para-margin-left: 4.0gd">
				<font size="2">
						<span lang="EN-US">
								<span style="mso-spacerun: yes">                                                                                     </span>
						</span>
				</font>
				<font size="2">
				</font>
		</p>
		<font face="宋体">
		</font>
<img src ="http://www.blogjava.net/soft/aggbug/82618.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/soft/" target="_blank">书法</a> 2006-11-21 22:08 <a href="http://www.blogjava.net/soft/archive/2006/11/21/82618.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JNI技术在嵌入式软件开发中的应用学习笔记之三</title><link>http://www.blogjava.net/soft/archive/2006/11/13/80789.html</link><dc:creator>书法</dc:creator><author>书法</author><pubDate>Sun, 12 Nov 2006 20:25:00 GMT</pubDate><guid>http://www.blogjava.net/soft/archive/2006/11/13/80789.html</guid><wfw:comment>http://www.blogjava.net/soft/comments/80789.html</wfw:comment><comments>http://www.blogjava.net/soft/archive/2006/11/13/80789.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.blogjava.net/soft/comments/commentRss/80789.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/soft/services/trackbacks/80789.html</trackback:ping><description><![CDATA[		<p>
				<font size="2">通过前两篇文章的介绍，现在给出一个JNI的HelloWrold应用例子，用于抛砖引玉：<br /><br />步骤：<br /><font color="#666666" size="3"><font color="#000000">       a.</font><font size="2"><font color="#000000">编写带有native声明的方法的java类<br />　　<br />　　b.使用javac命令编译所编写的java类<br />　　<br />　　c.使用javah ?jni java类名生成扩展名为h的头文件<br />　　<br />　　d.使用C/C++实现本地方法<br />　　<br />　　e.将C/C++编写的文件生成动态连接库<br />　　<br />　　f. 运行 ok<br /></font><br /></font></font>详细介绍：<br /><font color="#000000">      </font><font color="#000000">1) 编写java程序：<br />　　<br />　　这里以HelloWorld为例。<br />　　<br />　　代码1：<br />　　<br />　　class HelloWorld {<br />　　public native void displayHelloWorld();<br />　　<br />　　static {<br />　　System.loadLibrary("hello");<br />　　}<br />　　<br />　　public static void main(String[] args) {<br />　　new HelloWorld().displayHelloWorld();<br />　　}<br />　　}<br />　　<br />　　声明native方法：如果你想将一个方法做为一个本地方法的话，那么你就必须声明改方法为native的，并且不能实现。其中方法的参数和返回值在后面讲述。<br />　　<br />　　Load动态库：System.loadLibrary("hello");加载动态库（我们可以这样理解：我们的方法displayHelloWorld()没有实现，但是我们在下面就直接使用了，所以必须在使用之前对它进行初始化）这里一般是以static块进行加载的。同时需要注意的是System.loadLibrary();的参数“hello”是动态库的名字。<br />　　<br />　　main()方法<br />　　<br />　　2) 编译没有什么好说的了<br />　　<br />　　javac HelloWorld.java<br />　　<br />　　3) 生成扩展名为h的头文件<br />　　<br />　　javah ?jni HelloWorld<br />　　<br />　　头文件的内容：<br />　　/* DO NOT EDIT THIS FILE - it is machine generated */<br />　　#include <br />　　/* Header for class HelloWorld */<br />　　<br />　　#ifndef _Included_HelloWorld<br />　　#define _Included_HelloWorld<br />　　#ifdef __cplusplus<br />　　extern "C" {<br />　　#endif<br />　　/*<br />　　* Class:　　 HelloWorld<br />　　* Method:　　displayHelloWorld<br />　　* Signature: ()V<br />　　*/<br />　　JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld<br />　　(JNIEnv *, jobject);<br />　　<br />　　#ifdef __cplusplus<br />　　}<br />　　#endif<br />　　#endif<br />　　<br />　　（这里我们可以这样理解：这个h文件相当于我们在java里面的接口，这里声明了一个Java_HelloWorld_displayHelloWorld (JNIEnv *, jobject);方法，然后在我们的本地方法里面实现这个方法，也就是说我们在编写C/C++程序的时候所使用的方法名必须和这里的一致）。<br />　　<br />　　4) 编写本地方法<br />　　<br />　　实现和由javah命令生成的头文件里面声明的方法名相同的方法。<br />　　<br />　　代码2：<br />　　<br />　　1 #include <br />　　2 #include "HelloWorld.h"<br />　　3 #include <br />　　4 JNIEXPORT void JNICALL Java_HelloWorld_displayHelloWorld(JNIEnv *env, jobject obj)<br />　　{<br />　　printf("Hello world!\n");<br />　　return;<br />　　}<br />　　<br />　　注意代码2中的第1行，需要将jni.h（该文件可以在%JAVA_HOME%/include文件夹下面找到）文件引入，因为在程序中的JNIEnv、jobject等类型都是在该头文件中定义的；另外在第2行需要将HelloWorld.h头文件引入（我是这么理解的：相当于我们在编写java程序的时候，实现一个接口的话需要声明才可以，这里就是将HelloWorld.h头文件里面声明的方法加以实现。当然不一定是这样）。然后保存为HelloWorldImpl.c就ok了。<br />　　<br />　　5) 生成动态库<br />　　<br />　　这里以在Windows中为例，需要生成dll文件。在保存HelloWorldImpl.c文件夹下面，使用VC的编译器cl成。<br />　　<br />　　cl -I%java_home%\include -I%java_home%\include\win32 -LD HelloWorldImp.c -Fehello.dll<br />　　<br />　　注意：生成的dll文件名在选项-Fe后面配置，这里是hello，因为在HelloWorld.java文件中我们loadLibary的时候使用的名字是hello。当然这里修改之后那里也需要修改。另外需要将-I%java_home%\include -I%java_home%\include\win32参数加上，因为在第四步里面编写本地方法的时候引入了jni.h文件。<br />　　<br />　　6) 运行程序<br />　　<br />　　java HelloWorld就ok了。<br /></font><br />        如有问题，欢迎讨论交流。^_^<br /><br /></font>
		</p>
<img src ="http://www.blogjava.net/soft/aggbug/80789.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/soft/" target="_blank">书法</a> 2006-11-13 04:25 <a href="http://www.blogjava.net/soft/archive/2006/11/13/80789.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JNI技术在嵌入式软件开发中的应用学习笔记之二</title><link>http://www.blogjava.net/soft/archive/2006/11/13/80788.html</link><dc:creator>书法</dc:creator><author>书法</author><pubDate>Sun, 12 Nov 2006 20:16:00 GMT</pubDate><guid>http://www.blogjava.net/soft/archive/2006/11/13/80788.html</guid><wfw:comment>http://www.blogjava.net/soft/comments/80788.html</wfw:comment><comments>http://www.blogjava.net/soft/archive/2006/11/13/80788.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/soft/comments/commentRss/80788.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/soft/services/trackbacks/80788.html</trackback:ping><description><![CDATA[		<font size="2">接上：<br />(1)编写Java类代码<br />    其中，需要JNI实现的方法应当用native关键字声明。在该类中，用System．1oadLibrary()方法加载需要的动态链接库。关键代码如下：<br />    ／／Compute.java<br />    public class Compute{<br />    public native double comp (double params);<br />    static{<br />    ／／调用动态链接库<br />    System．loadLibrary(“mathlib”)；<br />    }<br />    <br />(2)编译成字节代码<br />    在这个过程中，由于采用了native关键字声明，Java编译器会忽视没有代码体的JNI方法部分。<br />   <br /> (3)生成相关JNI方法的头文件<br />    这个过程的实现一般是通过利用jlavah-jni * class生成的，也可以手工生成该文件；但是由于</font>
		<font size="2">Java</font>
		<font size="2">虚拟机是根据一定的命名规范完成对JNI方法的调用，所以手工编写头文件需要特别小心。<br />    上述文件产生的头文件部分代码如下：<br />    ／／Compute.h<br />    ;<br />    extern“C”{<br />    JNIEXPORT jdoubleJNICALL Java_Compute_comp(JNI-Env *, jobject, jdoubleArray)；<br />    ;<br />    JNI函数名称分为三部分：首先是Java关键字，供Java虚拟机识别；然后是调用者类名称(全限定的类名，其中用下划线代替名称分隔符)；最后是对应的方法名称，各段名称之间用下划线分割。<br />    JNI函数的参数也由三部分组成：首先是JNIEnv *,是一个指向JNI运行环境的指针；第二个参数随本地方法是静态还是非静态而有所不同一一非静态本地方法的第二个参数是对对象的引用，而静态本地方法的第二个参数是对其Java类的引用；其余的参数对应通常Java方法的参数，参数类型需要根据一定规则进行映射。</font>
		<p>
				<br />
				<font size="2">    (4)编写相应方法的实现代码<br />    在编码过程中，需要注意变量的长度问题，例如Java的整型变量长度为32位，而C语言为16位，所以要仔细核对变量类型映射表，防止在传值过程中出现问题。</font>
		</p>
		<p>
				<br />
				<font size="2">    (5)将JNI实现代码编译成动态链接库<br />    编译过程是利用C／C++编译器实现的，当要使用生成的动态链接库时，调用者类中需要显式调用该链接库。<br />    经过上述处理，基本上完成了一个包含本地化方法的Java类的开发。</font>
		</p>
		<p align="left">
				<font size="2">     3 基于JNI的嵌入式手机软件开发实例<br />    下面通过一个实例来描述运用</font>
				<font size="2">JNI技术</font>
				<font size="2">在手机上操纵摄像头，捕捉视频并存储图片的过程。<br />    (1)活动／状态图<br />    图2为捕捉视频并存储图片的活动／状态图</font>
				<img style="WIDTH: 479px; HEIGHT: 603px" height="603" src="http://www.blogjava.net/images/blogjava_net/soft/17148/o_s1.jpg" width="646" />
				<br />
				<br />                                                                                <a title="图二" href="/images/blogjava_net/soft/17148/r_s0.jpg" target="_blank"><font color="#ff0000">点击查看原图</font></a><br /><font size="2">根据图2的活动／状态，具体的对应步骤如下：<br />    ①发起该流程。<br />    ②发起流程后，建立文件用于存储图片。<br />    ③用指针获得分配的缓冲器，用于存储获得的帧。<br />    ④将指针压栈(序列化缓冲器)。由于手机的内存较小，为了防止内存泄漏，Symbian操作系统有一个Cleanup stack的要求，即在使用指针时，用PushL把指针压入栈中，使用完后再用Pop弹出栈．如果在中间调用导致崩溃的函数时果真出现了问题，那么Clean up stack可以通过调用该指针的析构函数回收占用的空间。<br />    ⑤操纵摄像头，捕捉视频，并将图像流从摄像头端传到缓冲器。<br />    ⑥将摄像头内的图像流存入缓冲器内，并将缓冲器内的流转化为文件流，存为jpg格式的文件，将指向缓冲器的指针弹栈。<br />    ⑦在过程⑥中，如果使用完了序列化的缓冲器，则要重新序列化缓冲器，以备后面使用。<br />    ⑧当接收到停止视频捕捉的信号后，关闭文件。<br />    ⑨流程结束。<br /> <br />     (2)运用JNI</font><font size="2">技术</font><font size="2">的视频捕捉<br />    子功能捕捉视频的实现是由操纵摄像头、视频播放(解码器准备)以及建立摄像头和手机之间的连接会话三个活动组成的。其中操纵摄像头是通过调用底层设备的驱动来实现的，需要利用JNI来实现，完成的方法包括准备、建立、删除、销毁摄像头等。视频播放的一系列过程也是通过c++代码来实现的，除了准备、建立、删除、销毁解码器外，还有开始、暂停、停止解码等。建立摄像头和手机之间的连接类似建立客户端和服务器连接，视频流从摄像头传到手机界面是通过多媒体会话来完成的。多媒体<br />会话的建立、关闭、摧毁以及会话建立后的发送、取消、读取数据等也是JNI的应用范畴。<br /></font><font size="2"><br />     结语<br />    主张采用纯Java的人们通常反对本地化代码的使用，认为JNI技术会影响</font><font size="2">程序</font><font size="2">的可移植性和安全性。还有一些人认为，在Java程序执行的过程中调用c／c++程序只是对过去混合编程技术的简单扩展，其实际目的是为了充分利用大量原有的c程序库。<br /></font><br /><font size="2">     其实，不必拘泥于严格的平台独立性限制，因为采用JNI技术只是针对一些严重影响Java性能的代码段。该部分可能只占源程序的极少部分，所以几乎可以不考虑该部分代码在主流平台之间移植的工作量。同时，也不必过分担心类型匹配问题，完全可以控制代码不出现这种错误。此外，也不必担心安全控制问题，因为Java安全模型已扩展为允许非系统类加载和调用本地方法，即如果在Java程序中直接调用c／c++语言产生的机器码，该部分代码的安全性就由Java虚拟机控制。<br /></font><br /><br /></p>
<img src ="http://www.blogjava.net/soft/aggbug/80788.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/soft/" target="_blank">书法</a> 2006-11-13 04:16 <a href="http://www.blogjava.net/soft/archive/2006/11/13/80788.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>JNI技术在嵌入式软件开发中的应用学习笔记之一</title><link>http://www.blogjava.net/soft/archive/2006/11/13/posoft.html</link><dc:creator>书法</dc:creator><author>书法</author><pubDate>Sun, 12 Nov 2006 19:46:00 GMT</pubDate><guid>http://www.blogjava.net/soft/archive/2006/11/13/posoft.html</guid><wfw:comment>http://www.blogjava.net/soft/comments/80787.html</wfw:comment><comments>http://www.blogjava.net/soft/archive/2006/11/13/posoft.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/soft/comments/commentRss/80787.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/soft/services/trackbacks/80787.html</trackback:ping><description><![CDATA[
		<p>
				<font size="2">嵌入式系统是以应用为中心、以计算机技术</font>
				<font size="2">为基础、软件硬件可裁剪、适应应用系统对功能、可靠性、成本、体积、功耗严格要求的专用计算机系统。嵌入式软件</font>
				<font size="2">的基本体系结构包括嵌入式实时操作系统RTOS(RealTime operating Systerrl)、嵌入式设备驱动程序</font>
				<font size="2">、嵌入式应用程序编程接口(中间件)和嵌入式应用程序。</font>
		</p>
		<p>
				<br />
				<font size="2">    现阶段，计算机应用的普及、互联网技术的实用以及纳米微电子技术的突破，正有力推动着21世纪的工业生产、商业活动、科学实验和家庭生活等领域自动化和信息化进程。全过程自动化产品制造、大范围电子商务活动、高度协同科学实验以及现代化家居生活，为嵌入式产品造就了崭新而巨大的商机。除了沟通信息高速公路的交换机、路由器和调制解调器，构建计算机集成制造系统(CIMS)所需的数据传输系统DCS(Data Communication System)和机器人以及规模较大的家用汽车电子系统，最有产量效益和时代特征的嵌入式产品应数因特网上的信息家电(information appliances），如网络可视电话、网络游戏机、电子商务、商务通(PDA)、移动电话以及多媒体产品(如电视机顶盒、DVD播放机、电子阅读机)。</font>
		</p>
		<p>
				<br />
				<font size="2">    众所周知，“一次编程，到处使用”的</font>
				<font size="2">Java </font>
				<font size="2">软件概念原本就是针对网上嵌入式小设备提出的，几经周折，目前SUN公司已推出了J2ME(Java 2 P1atform Micro Edition)针对信息家电的Java版本，其技术日趋成熟，开始投入使用。SUN公司Java虚拟机(JVM)技术的有序开放，使得Java软件真正实现跨平台运行，即Java应用小程序能够在带有JVM的任何硬软件系统上执行。加上Java语言本身所具有的安全性、可靠性和可移植性等特点，对实现瘦身上网的信息家电等网络设备十分有利，同时对嵌入式设备特别是上网设备软件编程技术产生了很大的影响。 </font>
		</p>
		<p>
				<font size="2">   1 Java的性能问题及几种解决方案<br />    Java程序也有其本身的缺陷，那就是其效率问题。由于Java是一种介于解释型和编译型之间的语言，其对内存的管理是通过JVM虚拟机来实现的，同样的程序，如果用编译型语言C来实现，其运行速度一般要比Java快得多。因此，提高Java的性能就显得十分重要。</font>
		</p>
		<p>
				<br />
				<font size="2">    迄今为止，人们为提高Java的运行速度而做出的许多努力，主要集中在程序设计的方法和模式选择方面。但是由于算法和设计模式的优化是通用的，对Java有效的优化算法和设计模式，对其他编译语言也基本适用，因此不能从根本上改变Java程序与编译型语言在执行效率方面的差异。</font>
		</p>
		<p>
				<br />
				<font size="2">    另外，JIT(Just In Time，及时编译)技术也是一个比较好的思想。它的基本原理是，首先，通过Java编译器把Java源代码编译成与平台无关的二进制字节码。然后，在Java程序真正执行之前，系统通过JIT编译器把Java的字节码编译为本地化机器码。最后，系统执行本地化机器码，不用对字节码进行解释。这样做的优点是，大大提高了Java程序的性能，缩短了加载程序的时间；同时，由于编译的结果并不在程序运行期间保存，因此也节约了存储空间。缺点是，由于JIT编译器对所有的代码都想优化，因此同样也占用了很多时间。</font>
		</p>
		<p>
				<br />
				<font size="2">    动态优化技术即提前编译为机器码的技术(dynamicopttmization，ahead of time technology)是提高Java性能的另一个尝试。动态优化技术充分利用了Java源码编译、字节码编译、动态编译和静态编译的技术。其输入是Java的源码或字节码。而输出是经过高度优化的可执行代码和动态库(WindoW中是．dil文件，UNIX中是共享库.a.so文件)。其优点是能大大提高程序的性能，缺点是破坏了Java的可移植性，也对Java的安全带来了一定的隐患。</font>
		</p>
		<p>
				<font size="2">     2 </font>
				<font size="2">JNI技术</font>
				<br />
				<font size="2">    实际上，有一种通常被忽视的技术可以在很大程度上解决这个难题，那就是JNI(Java Native Interface，Java本地化方法)。图l是JNI技术实现的一般步骤。<br /></font>
		</p>
		<p align="center">
				<img style="WIDTH: 313px; HEIGHT: 461px" height="461" src="http://www.blogjava.net/images/blogjava_net/soft/17148/o_s0.jpg" width="399" />
				<br />
				<br />
				<br />
				<a title="图一" href="/images/blogjava_net/soft/17148/r_s0.jpg" target="_blank">
						<font color="#ff0000">点击查看原图</font>
						<br />
				</a>                    <br /><br />                                                                                                                                                             </p>
<img src ="http://www.blogjava.net/soft/aggbug/80787.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/soft/" target="_blank">书法</a> 2006-11-13 03:46 <a href="http://www.blogjava.net/soft/archive/2006/11/13/posoft.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>