<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Voland.com.cn</title>
	<atom:link href="http://www.voland.com.cn/feed" rel="self" type="application/rss+xml" />
	<link>http://www.voland.com.cn</link>
	<description>人生百年,诸事记之</description>
	<lastBuildDate>Thu, 02 Feb 2012 23:09:02 +0000</lastBuildDate>
	<language>zh</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>北京十六方数据科技有限公司招聘java开发人员 年薪10W~15W</title>
		<link>http://www.voland.com.cn/16-party-data-technology-co-ltd-in-beijing-to-recruit-java-developer-salary-10w-15w</link>
		<comments>http://www.voland.com.cn/16-party-data-technology-co-ltd-in-beijing-to-recruit-java-developer-salary-10w-15w#comments</comments>
		<pubDate>Thu, 02 Feb 2012 23:08:26 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[一起分享]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=738</guid>
		<description><![CDATA[公司研发新产品,需要招聘两名java开发人员,公司以前从不加班,但目前公司研发新产品,在产品研发关键时候可能偶尔会有加班,加班一般安排在周末,占用一天时间,大家如有能力有兴趣,请发邮件到job1@16ds.com,这个招聘邮箱为研发部门专用 职位要求分别如下: 职位一:Java Swing 开发工程师 学 历： 大专及以上 招聘人数： 1 人 年薪:10W~15W 任职条件： 有2年及以上Java开发经验； 熟练掌握swing,有实际的swing C/S程序开发经验。对j2ee开发有一定经验 思维活跃、心思缜密，考虑问题全面，具备较强的钻研精神及学习能力； 具备良好的团队合作精神、性格开朗，优秀的语言表达能力； 有android开发经验者优先考虑。 工作职责： 按美工设计完成产品UI的实现(使用Swing) 理解产品需求，能够完成模块的详细设计及实现、编写相关的技术文档； 进行编码和单元测试、bug定位和修复，并根据要求修改、完善产品。 职位二:j2ee开发工程师 学 历： 大专及以上 招聘人数： 1 人 年薪:6W~12W 任职条件： 有1年及以上Java开发经验,对j2ee熟练掌握； 熟悉HTML、CSS,javascript的开发知识，熟悉jquery等JS框架为佳； 熟悉MYSQL,需要一定的SQL编写能力 思维活跃、心思缜密，考虑问题全面，具备较强的钻研精神及学习能力； 具备良好的团队合作精神、性格开朗，优秀的语言表达能力； 工作职责： 按美工设计完成产品WEB页面的实现(html,jquery,css) 理解产品需求，能够完成模块的详细设计及实现、编写相关的技术文档； 进行编码和单元测试、bug定位和修复，并根据要求修改、完善产品。]]></description>
			<content:encoded><![CDATA[<p>公司研发新产品,需要招聘两名java开发人员,公司以前从不加班,但目前公司研发新产品,在产品研发关键时候可能偶尔会有加班,加班一般安排在周末,占用一天时间,大家如有能力有兴趣,请发邮件到job1@16ds.com,这个招聘邮箱为研发部门专用<br />
职位要求分别如下: <span id="more-738"></span></p>
<p>职位一:Java Swing 开发工程师<br />
学    历： 大专及以上<br />
招聘人数： 1 人<br />
年薪:10W~15W </p>
<p>任职条件：<br />
    有2年及以上Java开发经验；<br />
    熟练掌握swing,有实际的swing C/S程序开发经验。对j2ee开发有一定经验<br />
    思维活跃、心思缜密，考虑问题全面，具备较强的钻研精神及学习能力；<br />
    具备良好的团队合作精神、性格开朗，优秀的语言表达能力；<br />
    有android开发经验者优先考虑。 </p>
<p>工作职责：<br />
    按美工设计完成产品UI的实现(使用Swing)<br />
    理解产品需求，能够完成模块的详细设计及实现、编写相关的技术文档；<br />
    进行编码和单元测试、bug定位和修复，并根据要求修改、完善产品。 </p>
<p>职位二:j2ee开发工程师<br />
学    历： 大专及以上<br />
招聘人数： 1 人<br />
年薪:6W~12W </p>
<p>任职条件：<br />
    有1年及以上Java开发经验,对j2ee熟练掌握；<br />
    熟悉HTML、CSS,javascript的开发知识，熟悉jquery等JS框架为佳；<br />
    熟悉MYSQL,需要一定的SQL编写能力<br />
    思维活跃、心思缜密，考虑问题全面，具备较强的钻研精神及学习能力；<br />
    具备良好的团队合作精神、性格开朗，优秀的语言表达能力； </p>
<p>工作职责：<br />
    按美工设计完成产品WEB页面的实现(html,jquery,css)<br />
    理解产品需求，能够完成模块的详细设计及实现、编写相关的技术文档；<br />
    进行编码和单元测试、bug定位和修复，并根据要求修改、完善产品。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/16-party-data-technology-co-ltd-in-beijing-to-recruit-java-developer-salary-10w-15w/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActiveMQ配置之配置连接密码</title>
		<link>http://www.voland.com.cn/activemq5-5-configuration-password</link>
		<comments>http://www.voland.com.cn/activemq5-5-configuration-password#comments</comments>
		<pubDate>Thu, 29 Dec 2011 05:32:45 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[配置]]></category>
		<category><![CDATA[ActiveMQ]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=734</guid>
		<description><![CDATA[1、控制台安全配置，打开conf/jetty.xml文件，找到 &#60;bean id=&#34;securityConstraint&#34; class=&#34;org.eclipse.jetty.http.security.Constraint&#34;&#62; &#60;property name=&#34;name&#34; value=&#34;BASIC&#34; /&#62; &#60;property name=&#34;roles&#34; value=&#34;admin&#34; /&#62; &#60;property name=&#34;authenticate&#34; value=&#34;false&#34; /&#62; &#60;/bean&#62; 将“false”改为“true”即可。用户名和密码存放在conf/credentials.properties文件中。 2、生产者和消费者连接MQ需要密码 打开conf/activemq.xml文件，在标签里的标签前加入： &#60;plugins&#62; &#60;simpleAuthenticationPlugin&#62; &#60;users&#62; &#60;authenticationUser username=&#34;${activemq.username}&#34; password=&#34;${activemq.password}&#34; groups=&#34;users,admins&#34;/&#62; &#60;/users&#62; &#60;/simpleAuthenticationPlugin&#62; &#60;/plugins&#62; 请注意,这个配置必须在标签前，否则启动ActiveMQ会报错。]]></description>
			<content:encoded><![CDATA[<p>1、控制台安全配置，打开conf/jetty.xml文件，找到</p>

<div class="wp_syntax"><div class="code"><pre class="config" style="font-family:monospace;">    &lt;bean id=&quot;securityConstraint&quot; class=&quot;org.eclipse.jetty.http.security.Constraint&quot;&gt;
        &lt;property name=&quot;name&quot; value=&quot;BASIC&quot; /&gt;
        &lt;property name=&quot;roles&quot; value=&quot;admin&quot; /&gt;
        &lt;property name=&quot;authenticate&quot; value=&quot;false&quot; /&gt;
    &lt;/bean&gt;</pre></div></div>

<p>   将“false”改为“true”即可。用户名和密码存放在conf/credentials.properties文件中。<br />
2、生产者和消费者连接MQ需要密码<br />
   打开conf/activemq.xml文件，在<broker>标签里的<systemUsage>标签前加入：</p>

<div class="wp_syntax"><div class="code"><pre class="config" style="font-family:monospace;">   &lt;plugins&gt;   
     &lt;simpleAuthenticationPlugin&gt;   
       &lt;users&gt;   
          &lt;authenticationUser username=&quot;${activemq.username}&quot; password=&quot;${activemq.password}&quot; groups=&quot;users,admins&quot;/&gt;   
       &lt;/users&gt;   
      &lt;/simpleAuthenticationPlugin&gt;   
   &lt;/plugins&gt;</pre></div></div>

<p>   请注意,这个配置必须在<systemUsage>标签前，否则启动ActiveMQ会报错。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/activemq5-5-configuration-password/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>重设置debian 6系统中mysql5.1的root密码</title>
		<link>http://www.voland.com.cn/reset-debian-6-root-password-for-system-mysql5-1</link>
		<comments>http://www.voland.com.cn/reset-debian-6-root-password-for-system-mysql5-1#comments</comments>
		<pubDate>Thu, 27 Oct 2011 08:44:39 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[常用]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=721</guid>
		<description><![CDATA[今天把一台服务器的系统由debian5升级到了debian6,升级后发现mysql没有启动起来,以前同样的升级也没有遇到过.那就重新安装一个mysql5.1吧,安装完成后,使用root登录不进去了! 使用 sudo cat /etc/mysql/debian.cnf 得到一个用户名为:debian-sys-maint,密码为:YkUUwTfIbqMxi8Vs的用户.然后使用 mysql -udebian-sys-maint -p 成功进入mysql,然后就修改root的密码,如下: UPDATE user SET Password=PASSWORD&#40;'newpassword'&#41; WHERE USER='root'; FLUSH PRIVILEGES; 这里再写几个常用的sql CREATE DATABASE IF NOT EXISTS RCG DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL PRIVILEGES ON RCG.* TO rcg@localhost IDENTIFIED BY &#8216;rcg&#8217; WITH GRANT OPTION;]]></description>
			<content:encoded><![CDATA[<p>今天把一台服务器的系统由debian5升级到了debian6,升级后发现mysql没有启动起来,以前同样的升级也没有遇到过.那就重新安装一个mysql5.1吧,安装完成后,使用root登录不进去了!<br />
使用</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo cat /etc/mysql/debian.cnf</pre></div></div>

<p>得到一个用户名为:debian-sys-maint,密码为:YkUUwTfIbqMxi8Vs的用户.然后使用</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;">mysql <span style="color: #66cc66;">-</span>udebian<span style="color: #66cc66;">-</span>sys<span style="color: #66cc66;">-</span>maint <span style="color: #66cc66;">-</span>p</pre></div></div>

<p>成功进入mysql,然后就修改root的密码,如下:</p>

<div class="wp_syntax"><div class="code"><pre class="sql" style="font-family:monospace;"><span style="color: #993333; font-weight: bold;">UPDATE</span> user <span style="color: #993333; font-weight: bold;">SET</span> Password<span style="color: #66cc66;">=</span>PASSWORD<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'newpassword'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">WHERE</span> USER<span style="color: #66cc66;">=</span><span style="color: #ff0000;">'root'</span>;
<span style="color: #993333; font-weight: bold;">FLUSH</span> PRIVILEGES;</pre></div></div>

<p>这里再写几个常用的sql<br />
CREATE DATABASE IF NOT EXISTS RCG DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;<br />
GRANT ALL PRIVILEGES ON RCG.* TO rcg@localhost IDENTIFIED BY &#8216;rcg&#8217; WITH GRANT OPTION;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/reset-debian-6-root-password-for-system-mysql5-1/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Myeclipse6.5破解类</title>
		<link>http://www.voland.com.cn/myeclipse6-5-po-jie-lei</link>
		<comments>http://www.voland.com.cn/myeclipse6-5-po-jie-lei#comments</comments>
		<pubDate>Mon, 10 Oct 2011 07:52:21 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[常用]]></category>
		<category><![CDATA[Myeclipse6.5]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=716</guid>
		<description><![CDATA[Myeclipse6.5可能大家也不常用了,我也基本不用,不过用到的时候,没有注册码也难受,在网上找到这个类来生成注册码,还是比较好用的.放在这里备忘: import java.text.DecimalFormat; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Calendar; &#160; public class Crack &#123; //myeclipseBlue6.5破解,运行即可得到key public static final void main&#40;String&#91;&#93; args&#41;&#123; String id=&#34;nortan&#34;; //这是指注册的名称 String num=&#34;999&#34;; System.out.println&#40;getSerial&#40;id,&#34;100&#34;,num,false&#41;&#41;; &#125; public static String getSerial&#40;String userId, String version, String licenseNum, boolean selected&#41; &#123; Calendar cal = Calendar.getInstance&#40;&#41;; cal.add&#40;1, 3&#41;; cal.add&#40;6, -1&#41;; NumberFormat nf = new DecimalFormat&#40;&#34;000&#34;&#41;; licenseNum = [...]]]></description>
			<content:encoded><![CDATA[<p>Myeclipse6.5可能大家也不常用了,我也基本不用,不过用到的时候,没有注册码也难受,在网上找到这个类来生成注册码,还是比较好用的.放在这里备忘:<span id="more-716"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.DecimalFormat</span><span style="color: #339933;">;</span>   
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.NumberFormat</span><span style="color: #339933;">;</span>   
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.text.SimpleDateFormat</span><span style="color: #339933;">;</span>   
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>   
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Crack <span style="color: #009900;">&#123;</span>   
<span style="color: #666666; font-style: italic;">//myeclipseBlue6.5破解,运行即可得到key  </span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>   
        <span style="color: #003399;">String</span> id<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;nortan&quot;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">//这是指注册的名称  </span>
        <span style="color: #003399;">String</span> num<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;999&quot;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>getSerial<span style="color: #009900;">&#40;</span>id,<span style="color: #0000ff;">&quot;100&quot;</span>,num,<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
    <span style="color: #009900;">&#125;</span>   
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getSerial<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userId, <span style="color: #003399;">String</span> version,   
            <span style="color: #003399;">String</span> licenseNum, <span style="color: #000066; font-weight: bold;">boolean</span> selected<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
        <span style="color: #003399;">Calendar</span> cal <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        cal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        cal.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span>, <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">NumberFormat</span> nf <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DecimalFormat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;000&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        licenseNum <span style="color: #339933;">=</span> nf.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Integer</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>licenseNum<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> verTime <span style="color: #339933;">=</span> selected <span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;-&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">SimpleDateFormat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yyMMdd&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">format</span><span style="color: #009900;">&#40;</span>cal.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">&quot;-1312310&quot;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//这的时间是指注册到期时间，可以自己修改  </span>
        <span style="color: #003399;">String</span> type <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;YE3MB-&quot;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> need <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>userId.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>   
                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>type<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>version<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>licenseNum<span style="color: #009900;">&#41;</span>   
                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>verTime<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> dx <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>need<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>   
                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                        <span style="color: #0000ff;">&quot;Decompiling this copyrighted software is a violation of both your license agreement and the Digital Millenium Copyright Act of 1998 (http://www.loc.gov/copyright/legislation/dmca.pdf). Under section 1204 of the DMCA, penalties range up to a $500,000 fine or up to five years imprisonment for a first offense. Think about it; pay for a license, avoid prosecution, and feel better about yourself.&quot;</span><span style="color: #009900;">&#41;</span>   
&nbsp;
                        .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>userId<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> suf <span style="color: #339933;">=</span> decode<span style="color: #009900;">&#40;</span>dx<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #003399;">String</span> code <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">StringBuffer</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>need<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>   
                <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>suf<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000000; font-weight: bold;">return</span> change<span style="color: #009900;">&#40;</span>code<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">int</span> decode<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">char</span> ac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> s.<span style="color: #006633;">toCharArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>   
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> ac.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> j <span style="color: #339933;">&lt;</span> k<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>   
            i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">31</span> <span style="color: #339933;">*</span> i <span style="color: #339933;">+</span> ac<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">Math</span>.<span style="color: #006633;">abs</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    <span style="color: #009900;">&#125;</span>   
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> change<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
        <span style="color: #000066; font-weight: bold;">byte</span> abyte0<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> s.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">char</span> ac<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span>s.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   
        <span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>   
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> k <span style="color: #339933;">=</span> abyte0.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> k<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   
            <span style="color: #000066; font-weight: bold;">int</span> j <span style="color: #339933;">=</span> abyte0<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">48</span> <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">57</span><span style="color: #009900;">&#41;</span>   
                j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> <span style="color: #cc66cc;">48</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">5</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">10</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">48</span><span style="color: #339933;">;</span>   
            <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">65</span> <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span>   
                j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> <span style="color: #cc66cc;">65</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">26</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">65</span><span style="color: #339933;">;</span>   
            <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>j <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">97</span> <span style="color: #339933;">&amp;&amp;</span> j <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">122</span><span style="color: #009900;">&#41;</span>   
                j <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>j <span style="color: #339933;">-</span> <span style="color: #cc66cc;">97</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">13</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">%</span> <span style="color: #cc66cc;">26</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">97</span><span style="color: #339933;">;</span>   
            ac<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#41;</span>j<span style="color: #339933;">;</span>   
        <span style="color: #009900;">&#125;</span>   
&nbsp;
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #003399;">String</span>.<span style="color: #006633;">valueOf</span><span style="color: #009900;">&#40;</span>ac<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   
    <span style="color: #009900;">&#125;</span>   
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/myeclipse6-5-po-jie-lei/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JTextField如何限制输入长度</title>
		<link>http://www.voland.com.cn/how-to-limit-input-length-of-jtextfield</link>
		<comments>http://www.voland.com.cn/how-to-limit-input-length-of-jtextfield#comments</comments>
		<pubDate>Thu, 29 Sep 2011 06:55:42 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[JTextField]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=713</guid>
		<description><![CDATA[关于JTextField如何限制输入长度,网上的做法一般是两种情况,第一种是对JTextField增加addKeyLisener事件,第二种是对Document的变化进行监听.实际这两种办法都不好,因为代码太乱!我的办法是重写Document中的insertString方法,来表达控制限制输入长度的目的. 在这里我把他封装成LimitDocument类,这个类的具体代码如下: import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; &#160; /** * 限制JtextField的最大输入 * @author nortan * */ public class LimitDocument extends PlainDocument &#123; //只充许输入maxLength 个字符 private int maxLength = 8; &#160; public LimitDocument&#40;int maxLength&#41; &#123; super&#40;&#41;; this.maxLength = maxLength; &#125; &#160; public LimitDocument&#40;Content c, int maxLength&#41; &#123; super&#40;c&#41;; this.maxLength = maxLength; &#125; private static final [...]]]></description>
			<content:encoded><![CDATA[<p>关于JTextField如何限制输入长度,网上的做法一般是两种情况,第一种是对JTextField增加addKeyLisener事件,第二种是对Document的变化进行监听.实际这两种办法都不好,因为代码太乱!我的办法是重写Document中的insertString方法,来表达控制限制输入长度的目的.<span id="more-713"></span><br />
在这里我把他封装成LimitDocument类,这个类的具体代码如下:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.AttributeSet</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.BadLocationException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.PlainDocument</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #008000; font-style: italic; font-weight: bold;">/**
 * 限制JtextField的最大输入
 * @author nortan
 *
 */</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> LimitDocument <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">PlainDocument</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #666666; font-style: italic;">//只充许输入maxLength 个字符</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">int</span> maxLength <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> LimitDocument<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> maxLength<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">maxLength</span> <span style="color: #339933;">=</span> maxLength<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> LimitDocument<span style="color: #009900;">&#40;</span>Content c, <span style="color: #000066; font-weight: bold;">int</span> maxLength<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">maxLength</span> <span style="color: #339933;">=</span> maxLength<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1L<span style="color: #339933;">;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> insertString<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> offset, <span style="color: #003399;">String</span> s, <span style="color: #003399;">AttributeSet</span> a<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">BadLocationException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">||</span> offset <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
            <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>  
        <span style="color: #009900;">&#125;</span>  
        <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> s.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getLength<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> maxLength <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  
                <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>  
            <span style="color: #009900;">&#125;</span>  
            <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006633;">insertString</span><span style="color: #009900;">&#40;</span>offset <span style="color: #339933;">+</span> i, s.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>i, i <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>,  
                    a<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
        <span style="color: #009900;">&#125;</span>  
        <span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>对于想控制输入长度的JTextField,只要调用如下代码就成:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//限制输入10个字符</span>
field.<span style="color: #006633;">setDocument</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> LimitDocument<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>这个类好不好用,我相信大家懂的</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/how-to-limit-input-length-of-jtextfield/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C++调用JVM.DLL来启动java程序</title>
		<link>http://www.voland.com.cn/c-calling-java-program-to-start-jvm-dll</link>
		<comments>http://www.voland.com.cn/c-calling-java-program-to-start-jvm-dll#comments</comments>
		<pubDate>Fri, 02 Sep 2011 09:55:16 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=707</guid>
		<description><![CDATA[eclipse可以使用startup.jar来启动,但一般会用eclipse.exe来启动程序.这样系统进程也是eclipse.exe,而不是java.exe或者javaw.exe.这个eclipse.exe是使用C调用jvm.dll来启动java程序,最近的项目是基于Swing的java程序,所以也需要写一个exe来启动程序. 原来已经做了一个startup.exe,是使用NSIS来实现的,这里代码就不写出来了,因为他没有多在意义,原因有二: 第一,他在静默状态下执行,360安全卫士认为他是一个病毒,好像以前诺顿也误报过.这里BS一下360安全卫士 第二,他执行javaw来调用java程序,进程显示还是javaw,这样不好看.在进程里看到叫nortan.exe多好,呵呵 使用C++调用JVM.DLL来启动java程序,先来看看别人画的一个原理图: 从这个图上中可以看出,最主要还是怎么使用C++加载jvm.dll,然后把其一系列的操作.根据这个思路,写出如下代码: #include &#60;windows.h&#62; #include &#60;jni.h&#62; #include &#60;string&#62; using namespace std; &#160; void vShowError&#40;string sErrorMessage&#41;; void vShowLastError&#40;string sErrorMessage&#41;; void vDestroyVM&#40;JNIEnv *env, JavaVM *jvm&#41;; void vAddOption&#40;string&#38; sName&#41;; &#160; JavaVMOption* vm_options; int mctOptions = 0; int mctOptionCapacity = 0; boolean GetApplicationHome&#40;char *buf, jint sz&#41;; typedef jint &#40;CALLBACK *CreateJavaVM&#41;&#40;JavaVM **pvm, JNIEnv **penv, void *args&#41;; [...]]]></description>
			<content:encoded><![CDATA[<p>eclipse可以使用startup.jar来启动,但一般会用eclipse.exe来启动程序.这样系统进程也是eclipse.exe,而不是java.exe或者javaw.exe.这个eclipse.exe是使用C调用jvm.dll来启动java程序,最近的项目是基于Swing的java程序,所以也需要写一个exe来启动程序.<br />
原来已经做了一个startup.exe,是使用NSIS来实现的,这里代码就不写出来了,因为他没有多在意义,原因有二:<br />
第一,他在静默状态下执行,360安全卫士认为他是一个病毒,好像以前诺顿也误报过.这里BS一下360安全卫士<br />
第二,他执行javaw来调用java程序,进程显示还是javaw,这样不好看.在进程里看到叫nortan.exe多好,呵呵</p>
<p>使用C++调用JVM.DLL来启动java程序,先来看看别人画的一个原理图:<span id="more-707"></span><br />
<div id="attachment_708" class="wp-caption aligncenter" style="width: 324px"><img src="http://www.voland.com.cn/wp-content/uploads/2011/09/218717.gif" alt="java启动原理图" title="218717" width="314" height="308" class="size-full wp-image-708" /><p class="wp-caption-text">java启动原理图</p></div><br />
从这个图上中可以看出,最主要还是怎么使用C++加载jvm.dll,然后把其一系列的操作.根据这个思路,写出如下代码:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;windows.h&gt;</span>
<span style="color: #339933;">#include &lt;jni.h&gt;</span>
<span style="color: #339933;">#include &lt;string&gt;</span>
using namespace std<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> vShowError<span style="color: #009900;">&#40;</span><span style="color: #993333;">string</span> sErrorMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">void</span> vShowLastError<span style="color: #009900;">&#40;</span><span style="color: #993333;">string</span> sErrorMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">void</span> vDestroyVM<span style="color: #009900;">&#40;</span>JNIEnv <span style="color: #339933;">*</span>env<span style="color: #339933;">,</span> JavaVM <span style="color: #339933;">*</span>jvm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">void</span> vAddOption<span style="color: #009900;">&#40;</span>string<span style="color: #339933;">&amp;</span> sName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
JavaVMOption<span style="color: #339933;">*</span> vm_options<span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> mctOptions <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> mctOptionCapacity <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
boolean GetApplicationHome<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buf<span style="color: #339933;">,</span> jint sz<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">typedef</span> jint <span style="color: #009900;">&#40;</span>CALLBACK <span style="color: #339933;">*</span>CreateJavaVM<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>JavaVM <span style="color: #339933;">**</span>pvm<span style="color: #339933;">,</span> JNIEnv <span style="color: #339933;">**</span>penv<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> WINAPI WinMain<span style="color: #009900;">&#40;</span>HINSTANCE hInstance<span style="color: #339933;">,</span> HINSTANCE hPrevInstance<span style="color: #339933;">,</span> PSTR szCmdLine<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> iCmdShow<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    JNIEnv <span style="color: #339933;">*</span>env<span style="color: #339933;">;</span>
    JavaVM <span style="color: #339933;">*</span>jvm<span style="color: #339933;">;</span>
    jint jintVMStartupReturnValue<span style="color: #339933;">;</span>
    jclass jclassStartup<span style="color: #339933;">;</span>
    jmethodID midStartup<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// 确定各种文件所在的路径</span>
    <span style="color: #666666; font-style: italic;">// -应用的主目录</span>
    <span style="color: #993333;">char</span> home<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2000</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>GetApplicationHome<span style="color: #009900;">&#40;</span>home<span style="color: #339933;">,</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>home<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        vShowError<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;不能确定应用的主目录。&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #993333;">string</span> sAppHome<span style="color: #009900;">&#40;</span>home<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">string</span> sOption_AppHome <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;-Ddodo.home=&quot;</span> <span style="color: #339933;">+</span> sAppHome<span style="color: #339933;">;</span>
    <span style="color: #993333;">string</span> sJREPath <span style="color: #339933;">=</span> sAppHome <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;\\jre&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// -VM路径</span>
    <span style="color: #993333;">string</span> sRuntimePath <span style="color: #339933;">=</span> sJREPath <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;\<span style="color: #000099; font-weight: bold;">\b</span>in\\client&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">string</span> sJVMpath <span style="color: #339933;">=</span> sRuntimePath <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;\\jvm.dll&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// -启动路径</span>
    <span style="color: #993333;">string</span> sBootPath <span style="color: #339933;">=</span> sJREPath <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;\\lib&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">string</span> sOption_BootPath <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;-Dsun.boot.class.path=&quot;</span> <span style="color: #339933;">+</span> sBootPath<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// -CLASSPATH</span>
	<span style="color: #993333;">string</span> sClassPath <span style="color: #339933;">=</span> sAppHome <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;\\main\\startup.jar&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #993333;">string</span> sOption_ClassPath <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;-Djava.class.path=&quot;</span> <span style="color: #339933;">+</span> sClassPath<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// 设置VM参数</span>
    <span style="color: #666666; font-style: italic;">// vAddOption(string(&quot;-verbose&quot;));</span>
    vAddOption<span style="color: #009900;">&#40;</span>sOption_ClassPath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    vAddOption<span style="color: #009900;">&#40;</span>sOption_AppHome<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// VM初始化参数</span>
    JavaVMInitArgs vm_args<span style="color: #339933;">;</span>
    vm_args.<span style="color: #202020;">version</span> <span style="color: #339933;">=</span> <span style="color: #208080;">0x00010002</span><span style="color: #339933;">;</span>
    vm_args.<span style="color: #202020;">options</span> <span style="color: #339933;">=</span> vm_options<span style="color: #339933;">;</span>
    vm_args.<span style="color: #202020;">nOptions</span> <span style="color: #339933;">=</span> mctOptions<span style="color: #339933;">;</span>
    vm_args.<span style="color: #202020;">ignoreUnrecognized</span> <span style="color: #339933;">=</span> JNI_TRUE<span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// 装入JVM库</span>
    HINSTANCE hJVM <span style="color: #339933;">=</span> LoadLibrary<span style="color: #009900;">&#40;</span>sJVMpath.<span style="color: #202020;">c_str</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> hJVM <span style="color: #339933;">==</span> NULL <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        vShowLastError<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;不能从下面的路径装入JVM：&quot;</span> <span style="color: #339933;">+</span> sJVMpath<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// 启动1.2/3/4 VM</span>
    CreateJavaVM lpfnCreateJavaVM <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>CreateJavaVM<span style="color: #009900;">&#41;</span> GetProcAddress<span style="color: #009900;">&#40;</span>hJVM<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;JNI_CreateJavaVM&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    jintVMStartupReturnValue <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">*</span>lpfnCreateJavaVM<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>jvm<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>env<span style="color: #339933;">,</span> <span style="color: #339933;">&amp;</span>vm_args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// 是否成功？</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jintVMStartupReturnValue <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">string</span> sErrorMessage <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;创建VM失败。&quot;</span><span style="color: #339933;">;</span>
        vShowError<span style="color: #009900;">&#40;</span>sErrorMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        vDestroyVM<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> jvm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// 要启动的类</span>
    <span style="color: #993333;">string</span> sStartupClass <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;DodoStartup&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// 注意句点符号已经被转换成斜杠</span>
    jclassStartup <span style="color: #339933;">=</span> env<span style="color: #339933;">-&gt;</span>FindClass<span style="color: #009900;">&#40;</span>sStartupClass.<span style="color: #202020;">c_str</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jclassStartup <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">string</span> sErrorMessage <span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;找不到启动类[&quot;</span> <span style="color: #339933;">+</span>sStartupClass <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #339933;">;</span>
        vShowError<span style="color: #009900;">&#40;</span>sErrorMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        vDestroyVM<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> jvm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// 要启动的方法</span>
    <span style="color: #993333;">string</span> sStartupMethod_Identifier <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;main&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">string</span> sStartupMethod_TypeDescriptor <span style="color: #339933;">=</span><span style="color: #ff0000;">&quot;([Ljava/lang/String;)V&quot;</span><span style="color: #339933;">;</span>
    midStartup <span style="color: #339933;">=</span> env<span style="color: #339933;">-&gt;</span>GetStaticMethodID<span style="color: #009900;">&#40;</span>jclassStartup<span style="color: #339933;">,</span>
    sStartupMethod_Identifier.<span style="color: #202020;">c_str</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    sStartupMethod_TypeDescriptor.<span style="color: #202020;">c_str</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>midStartup <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">string</span> sErrorMessage <span style="color: #339933;">=</span> <span style="color: #ff0000;">&quot;找不到启动方法[&quot;</span><span style="color: #339933;">+</span> sStartupClass <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #339933;">+</span> sStartupMethod_Identifier
        <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;]，类型描述符是[&quot;</span> <span style="color: #339933;">+</span> sStartupMethod_TypeDescriptor <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #339933;">;</span>
        vShowError<span style="color: #009900;">&#40;</span>sErrorMessage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        vDestroyVM<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> jvm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// 构造启动方法的参数</span>
    jstring jstringExampleArg<span style="color: #339933;">;</span>
    jclass jclassString<span style="color: #339933;">;</span>
    jobjectArray jobjectArray_args<span style="color: #339933;">;</span>
    jstringExampleArg <span style="color: #339933;">=</span> env<span style="color: #339933;">-&gt;</span>NewStringUTF<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;string1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jstringExampleArg <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        vDestroyVM<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> jvm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    jclassString <span style="color: #339933;">=</span> env<span style="color: #339933;">-&gt;</span>FindClass<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;java/lang/String&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    jobjectArray_args <span style="color: #339933;">=</span> env<span style="color: #339933;">-&gt;</span>NewObjectArray<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #339933;">,</span> jclassString<span style="color: #339933;">,</span> jstringExampleArg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jobjectArray_args <span style="color: #339933;">==</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        vDestroyVM<span style="color: #009900;">&#40;</span>env<span style="color: #339933;">,</span> jvm<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// 调用启动方法启动Java程序</span>
    env<span style="color: #339933;">-&gt;</span>CallStaticVoidMethod<span style="color: #009900;">&#40;</span>jclassStartup<span style="color: #339933;">,</span> midStartup<span style="color: #339933;">,</span> jobjectArray_args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// 在退出之前尝试分离主线程</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>jvm<span style="color: #339933;">-&gt;</span>DetachCurrentThread<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        vShowError<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;分离主线程失败。<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// 只要还有非守护线程，下面的调用将一直被挂起</span>
    jvm<span style="color: #339933;">-&gt;</span>DestroyJavaVM<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #993333;">void</span> vDestroyVM<span style="color: #009900;">&#40;</span>JNIEnv <span style="color: #339933;">*</span>env<span style="color: #339933;">,</span> JavaVM <span style="color: #339933;">*</span>jvm<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>env<span style="color: #339933;">-&gt;</span>ExceptionOccurred<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        env<span style="color: #339933;">-&gt;</span>ExceptionDescribe<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    jvm<span style="color: #339933;">-&gt;</span>DestroyJavaVM<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> vShowError<span style="color: #009900;">&#40;</span><span style="color: #993333;">string</span> sError<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    MessageBox<span style="color: #009900;">&#40;</span>NULL<span style="color: #339933;">,</span> sError.<span style="color: #202020;">c_str</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;错误&quot;</span><span style="color: #339933;">,</span> MB_OK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* 在对话框中显示错误信息，括号内包含
的GetLastError错误信息 */</span>
<span style="color: #993333;">void</span> vShowLastError<span style="color: #009900;">&#40;</span><span style="color: #993333;">string</span> sLocalError<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    LPVOID lpSystemMsgBuf<span style="color: #339933;">;</span>
    FormatMessage<span style="color: #009900;">&#40;</span> FORMAT_MESSAGE_ALLOCATE_BUFFER <span style="color: #339933;">|</span>
    FORMAT_MESSAGE_FROM_SYSTEM <span style="color: #339933;">|</span> FORMAT_MESSAGE_IGNORE_INSERTS<span style="color: #339933;">,</span>
    NULL<span style="color: #339933;">,</span> GetLastError<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> MAKELANGID<span style="color: #009900;">&#40;</span>LANG_NEUTRAL<span style="color: #339933;">,</span> SUBLANG_DEFAULT<span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#40;</span>LPTSTR<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>lpSystemMsgBuf<span style="color: #339933;">,</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> NULL <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #993333;">string</span> sSystemError <span style="color: #339933;">=</span> <span style="color: #993333;">string</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>LPTSTR<span style="color: #009900;">&#41;</span>lpSystemMsgBuf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    vShowError<span style="color: #009900;">&#40;</span>sLocalError <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot; [&quot;</span> <span style="color: #339933;">+</span> sSystemError <span style="color: #339933;">+</span> <span style="color: #ff0000;">&quot;]&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> vAddOption<span style="color: #009900;">&#40;</span>string<span style="color: #339933;">&amp;</span> sValue<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    mctOptions<span style="color: #339933;">++;</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>mctOptions <span style="color: #339933;">&gt;=</span> mctOptionCapacity<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>mctOptionCapacity <span style="color: #339933;">==</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            mctOptionCapacity <span style="color: #339933;">=</span> <span style="color: #0000dd;">3</span><span style="color: #339933;">;</span>
            vm_options <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>JavaVMOption<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>malloc<span style="color: #009900;">&#40;</span>mctOptionCapacity <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>JavaVMOption<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            JavaVMOption <span style="color: #339933;">*</span>tmp<span style="color: #339933;">;</span>
            mctOptionCapacity <span style="color: #339933;">*=</span> <span style="color: #0000dd;">2</span><span style="color: #339933;">;</span>
            tmp <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>JavaVMOption<span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>malloc<span style="color: #009900;">&#40;</span>mctOptionCapacity <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>JavaVMOption<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            memcpy<span style="color: #009900;">&#40;</span>tmp<span style="color: #339933;">,</span> vm_options<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>mctOptions<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> <span style="color: #993333;">sizeof</span><span style="color: #009900;">&#40;</span>JavaVMOption<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            free<span style="color: #009900;">&#40;</span>vm_options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            vm_options <span style="color: #339933;">=</span> tmp<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    vm_options<span style="color: #009900;">&#91;</span>mctOptions<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>.<span style="color: #202020;">optionString</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>sValue.<span style="color: #202020;">c_str</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* 如果缓冲区是&quot;c:\app\bin\java&quot;，则把&quot;c:\app&quot;放入buf。*/</span>
jboolean GetApplicationHome<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buf<span style="color: #339933;">,</span> jint sz<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>cp<span style="color: #339933;">;</span>
    GetModuleFileName<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #339933;">,</span> buf<span style="color: #339933;">,</span> sz<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #339933;">*</span>strrchr<span style="color: #009900;">&#40;</span>buf<span style="color: #339933;">,</span> <span style="color: #ff0000;">'\<span style="color: #000099; font-weight: bold;">\'</span>) = '</span>\<span style="color: #0000dd;">0</span><span style="color: #ff0000;">';
    if ((cp = strrchr(buf, '</span>\\<span style="color: #ff0000;">')) == 0) {
        // 如果应用程序放在驱动器的根目录下，且不存在bin目录
        // 会出现这种情形
        buf[0] = '</span>\<span style="color: #0000dd;">0</span><span style="color: #ff0000;">';
        return JNI_FALSE;
    }
    return JNI_TRUE;
}</span></pre></div></div>

<p>象大多数Windows程序一样，启动器需要一个WinMain()入口。与Windows这一特定平台相关的问题，除了必要的类型转换（例如对CreateJavaVM()的转换）之外，另外一个要注意的地方就是装入VM的DLL文件。装入DLL文件最可靠的办法是显式地调用LoadLibrary()。装入JVM之后，就可以利用内核调用GetProcAddress()获得CreateJavaVM()的函数指针，然后调用该指针启动VM。<br />
注意,这里的启动类是DodoStartup,这个类并没有包路径,如果是com.voland.DodoStartup,这个串可能就得写成”com/voland/DodoStartup”,因为FindClass()是一个虚拟机调用，而虚拟机内部用斜杠作为分隔符。</p>
<p>Java程序启动后执行的第一个方法称为启动方法，通常是main()。本例通过JNI调用GetStaticMethodID()获得启动方法的ID。GetStaticMethodID()要求指定方法的名字（“main”）和方法的类型描述符（“([Ljava/lang/String;)V”）。这个类型描述符表示方法的参数是一个字符串的数组，返回值类型是void。有关类型描述符的更详细的说明，请参见JVM相关资料。注意，从这里可以看出，在使用定制启动器时，Java程序的启动方法不必一定是static void的main方法，可以用任何方法作为Java程序中第一个执行的方法，甚至包括实例方法或构造函数。</p>
<p>示例程序中最后一个需要注意的地方是jvm->DestroyJavaVM()调用。从表面看起来，这个语句似乎是程序执行后进行清理工作的方法，可有可无。其实不然，如果Java程序是多线程的，在调用这个方法时程序仍旧在运行。例如，对于一个运行着的Swing程序，如果它的main方法结束，DestroyJavaVM()的执行将被阻塞，直至所有非守护线程都执行完毕，所以这行代码是必不可少的。如果省略这行代码，则当主线程执行完毕，即使其他线程（例如Swing GUI的事件循环）仍旧在运行，整个程序也会立即退出。</p>
<p>编译这个类需要用到jdk相关jni的c头文件,通过Visual C++ 6的菜单Tools→Options打开选项对话框。在Directories标签页下添加JDK的相关目录到Include和目录下。 如下图,注意你的jdk版本与路径的修改:<br />
<div id="attachment_709" class="wp-caption aligncenter" style="width: 556px"><img src="http://www.voland.com.cn/wp-content/uploads/2011/09/bd524fdb-4ad9-3074-bebf-4896bbfad938.jpg" alt="配置jni等头文件到开发环境中" title="bd524fdb-4ad9-3074-bebf-4896bbfad938" width="546" height="384" class="size-full wp-image-709" /><p class="wp-caption-text">配置jni等头文件到开发环境中</p></div></p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/c-calling-java-program-to-start-jvm-dll/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubuntu下Subclipse报failed to load javahl library的解决办法</title>
		<link>http://www.voland.com.cn/subclipse-under-ubuntu-report-failed-to-load-javahl-library-solution</link>
		<comments>http://www.voland.com.cn/subclipse-under-ubuntu-report-failed-to-load-javahl-library-solution#comments</comments>
		<pubDate>Thu, 01 Sep 2011 02:00:05 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[常用]]></category>
		<category><![CDATA[操作系统]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=698</guid>
		<description><![CDATA[最近买了一T61p,买回后直接安装Ubuntu 10.04,安装Eclipse并安装Subclipse1.6x插件后,使用svn过程中报如下错误: Failed to load JavaHL Library. These are the errors that were encountered: no libsvnjavahl-1 in java.library.path no svnjavahl-1 in java.library.path /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: no suitable image found. Did find: /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: mach-o, but wrong architecture 原来是缺少一些关联文件,去subclipse的Wiki看了看,说需要安装libsvn-java,在Ubuntu 下安装很简单,命令如下: sudo apt-get install libsvn-java 安装完后,这文件在/usr/lib/jni目录下,这个目录并不是eclipse的java.library.path路径之一,所以还需要修改eclipse.ini来告诉eclipse去哪找这个libsvn-java相关的文件. 打开eclipse.ini,在最后行加入如下内容(注意换行) -Djava.library.path=/usr/lib/jni]]></description>
			<content:encoded><![CDATA[<p>最近买了一T61p,买回后直接安装Ubuntu 10.04,安装Eclipse并安装Subclipse1.6x插件后,使用svn过程中报如下错误:<br />
<code><br />
Failed to load JavaHL Library.<br />
These are the errors that were encountered:<br />
no libsvnjavahl-1 in java.library.path<br />
no svnjavahl-1 in java.library.path<br />
/opt/local/lib/libsvnjavahl-1.0.0.0.dylib:  no suitable image found.  Did find:  /opt/local/lib/libsvnjavahl-1.0.0.0.dylib: mach-o, but wrong architecture<br />
</code><br />
原来是缺少一些关联文件,去subclipse的Wiki看了看,说需要安装libsvn-java,在Ubuntu 下安装很简单,命令如下:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo apt-get install libsvn-java</pre></div></div>

<p>安装完后,这文件在/usr/lib/jni目录下,这个目录并不是eclipse的java.library.path路径之一,所以还需要修改eclipse.ini来告诉eclipse去哪找这个libsvn-java相关的文件.<br />
打开eclipse.ini,在最后行加入如下内容(注意换行)</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">-Djava.library.path=/usr/lib/jni</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/subclipse-under-ubuntu-report-failed-to-load-javahl-library-solution/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>使用java实现Windows Explorer左边的常见任务</title>
		<link>http://www.voland.com.cn/windows-explorer-using-java-to-achieve-common-tasks-left</link>
		<comments>http://www.voland.com.cn/windows-explorer-using-java-to-achieve-common-tasks-left#comments</comments>
		<pubDate>Thu, 18 Aug 2011 02:40:04 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[swing]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=692</guid>
		<description><![CDATA[java实际可以做很多事情,只能你能想到的,理论上都可以实现出来,这文章介绍使用java实现Windows Explorer左边的常见任务.这文章原作者不是我,是WilliamChen,他写了很多美文章,我怕哪天他的文章都没有了,都删除了,所以把这些关键的图片,文字及代码存储起来.并在代码中保留原作者的名字.不做任何修改 下面的Enable Animation的JCheckBox可以设置是否使用动画效果。选择上折叠和展开就具有动画效果。 这个组件的类名是dyno.swing.beans.FolderPane。使用比较简单： FolderPane fp=new FolderPane&#40;&#41;;//设置是否有动画效果，缺省没有 fp.setAnimated&#40;true&#41;;//添加子面板 fp.addFolder&#40;&#34;文件和文件夹任务&#34;, getFileFolderPane&#40;&#41;&#41;; fp.addFolder&#40;&#34;其他位置&#34;, getOtherPlacePane&#40;&#41;&#41;; fp.addFolder&#40;&#34;详细信息&#34;, getDetailsPane&#40;&#41;&#41;; add&#40;fp, BorderLayout.CENTER&#41;; 主要接口有两个： //设置是否要动画效果 public void setAnimated&#40;boolean b&#41; //添加面板，title是面板标题文字，content是应用程序组件 public void addFolder&#40;String title, JComponent content&#41; 这个演示的源码可以从这儿下载，是一个NetBeans工程。编译之后，直接双击foldered_pane.jar既可观看效果。源代码中有详细的注解。]]></description>
			<content:encoded><![CDATA[<p>java实际可以做很多事情,只能你能想到的,理论上都可以实现出来,这文章介绍使用java实现Windows Explorer左边的常见任务.这文章原作者不是我,是WilliamChen,他写了很多美文章,我怕哪天他的文章都没有了,都删除了,所以把这些关键的图片,文字及代码存储起来.并在代码中保留原作者的名字.不做任何修改<br />
<img src="http://www.voland.com.cn/wp-content/uploads/2011/08/4b6047bcbcb26eedce10b.png" alt="" title="4b6047bcbcb26eedce10b" width="238" height="314" class="aligncenter size-full wp-image-693" /><br />
下面的Enable Animation的JCheckBox可以设置是否使用动画效果。选择上折叠和展开就具有动画效果。<br />
这个组件的类名是dyno.swing.beans.FolderPane。使用比较简单： <span id="more-692"></span></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    FolderPane fp<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> FolderPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//设置是否有动画效果，缺省没有</span>
    fp.<span style="color: #006633;">setAnimated</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//添加子面板      </span>
    fp.<span style="color: #006633;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;文件和文件夹任务&quot;</span>, getFileFolderPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
    fp.<span style="color: #006633;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;其他位置&quot;</span>, getOtherPlacePane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
    fp.<span style="color: #006633;">addFolder</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;详细信息&quot;</span>, getDetailsPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>      
    add<span style="color: #009900;">&#40;</span>fp, <span style="color: #003399;">BorderLayout</span>.<span style="color: #006633;">CENTER</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>主要接口有两个：</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #666666; font-style: italic;">//设置是否要动画效果      </span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> setAnimated<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">boolean</span> b<span style="color: #009900;">&#41;</span>
    <span style="color: #666666; font-style: italic;">//添加面板，title是面板标题文字，content是应用程序组件</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addFolder<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> title, <span style="color: #003399;">JComponent</span> content<span style="color: #009900;">&#41;</span></pre></div></div>

<p>这个演示的源码可以从<a href="/wp-content/uploads/foldered_pane.zip">这儿</a>下载，是一个NetBeans工程。编译之后，直接双击foldered_pane.jar既可观看效果。源代码中有详细的注解。 </p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/windows-explorer-using-java-to-achieve-common-tasks-left/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Debian6下安装Mysql,Ubuntu下适用</title>
		<link>http://www.voland.com.cn/debian6-install-mysql-ubuntu-applies</link>
		<comments>http://www.voland.com.cn/debian6-install-mysql-ubuntu-applies#comments</comments>
		<pubDate>Mon, 08 Aug 2011 05:53:16 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[常用]]></category>
		<category><![CDATA[数据库]]></category>
		<category><![CDATA[配置]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=686</guid>
		<description><![CDATA[Debian下安装软件的方便性就不在提了,这里直接讲Debian下安装MYSQL,请分别执行如下命令: sudo apt-get update sudo apt-get installl mysql-server 执行第二条命令的时候,会提示输入root的密码,如下图: 接下来再确认密码,确认后,提示一堆信息,就安装好了.]]></description>
			<content:encoded><![CDATA[<p>Debian下安装软件的方便性就不在提了,这里直接讲Debian下安装MYSQL,请分别执行如下命令:</p>

<div class="wp_syntax"><div class="code"><pre class="sh" style="font-family:monospace;">sudo apt-get update
sudo apt-get installl mysql-server</pre></div></div>

<p>执行第二条命令的时候,会提示输入root的密码,如下图:<br />
<div id="attachment_687" class="wp-caption aligncenter" style="width: 610px"><img src="http://www.voland.com.cn/wp-content/uploads/2011/08/mysqlconfig.jpg" alt="mysqlconfig" title="mysqlconfig" width="600" height="346" class="size-full wp-image-687" /><p class="wp-caption-text">mysql config</p></div><br />
接下来再确认密码,确认后,提示一堆信息,就安装好了.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/debian6-install-mysql-ubuntu-applies/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>yardvps试用过程中的烦恼</title>
		<link>http://www.voland.com.cn/yardvps-troubles-during-the-trial</link>
		<comments>http://www.voland.com.cn/yardvps-troubles-during-the-trial#comments</comments>
		<pubDate>Mon, 08 Aug 2011 03:32:29 +0000</pubDate>
		<dc:creator>Nortan</dc:creator>
				<category><![CDATA[一起分享]]></category>
		<category><![CDATA[VPS]]></category>
		<category><![CDATA[yardvps]]></category>

		<guid isPermaLink="false">http://www.voland.com.cn/?p=681</guid>
		<description><![CDATA[不得不承认yardvps的VPS便宜,TREE 1为XEN虚拟机512M的内存才$7.95/Month,加上8月有20%的优惠码,忍不住就下手了,因为我想找一个能很好支持java的vps(需要真实内存大,openVZ的主机不太合适),于是注册,下订单,支付宝付钱,一切尽在掌握中&#8230; 好景不长,交钱后,苦苦等了一个晚上才开通,看到自己的独立IP,心里那个高兴呀,马上使用ssh登陆,结果&#8230;你懂的,我中奖了,登陆没有反应!!!于是在ping一下,妈的,不通!!!服务器的状态是绿绿的Online竞然ping不通!!!难道是这个ip被Great Wall了?带个这个疑问,我马上登陆我朋友的国外vps,再ping,还是不通!!!就这样我又是reboot,又是shutdown,又是boot,还是不通,甚至连他提供的在线ssh连接工具也连接不上. 好吧我终于明白,网上的传说是真的,现在我只能发支持单,让他们的技术去解决吧,哥英文不好,不过写的估计他们也看得懂,就这样等了一天问题还是没有解决!没有人理我的支持单,于是哥就与他们的在线人员沟通,告知我他们的技术这会都忙,请我发一个邮件给他们,会处理的!!!这样就又等等了半天. 下午的时候,我忽然想起来他是可以重装系统了,在他们的后台找了半天,没有找到在哪里重装系统,再看他们给我发的开通邮件,原来管理链接发到我邮箱了,赶快登录上去,重新安装系统,再ping,通了,一切正常! 现在VPS使用两三天了,对他还不了解,但发现他是不太稳定,特别是网络,我在VPS上下载他们的测速链接,50M那个使用wget命令,最慢的时候下载速度只有114K(晚上11点了),今天又测试了一下,最快时达到了1.04M,可见网速很不稳定,一般快都称不上,我朋友那个传说垃圾中的战斗机BurstNet(burst)下载速度反而很快,至少有2M以上. yardvps便宜,给的流量又大,但技术支持不好,别人没有空根本不会考虑帮助你,还可能会出一些想不到问题,速度也很不稳定(可能是一台服务器上的VPS太多了),CPU的核心也只有一个,所以真正想做网站的朋友还不不要考虑了.只推荐给入门学习的对稳定性不高又囊中羞涩的朋友,注意,这个是我个人的使用经验,不构成购买与购买建议.]]></description>
			<content:encoded><![CDATA[<p>不得不承认yardvps的VPS便宜,TREE 1为XEN虚拟机512M的内存才$7.95/Month,加上8月有20%的优惠码,忍不住就下手了,因为我想找一个能很好支持java的vps(需要真实内存大,openVZ的主机不太合适),于是注册,下订单,支付宝付钱,一切尽在掌握中&#8230;</p>
<p>好景不长,交钱后,苦苦等了一个晚上才开通,看到自己的独立IP,心里那个高兴呀,马上使用ssh登陆,结果&#8230;你懂的,我中奖了,登陆没有反应!!!于是在ping一下,妈的,不通!!!服务器的状态是绿绿的Online竞然ping不通!!!难道是这个ip被Great Wall了?带个这个疑问,我马上登陆我朋友的国外vps,再ping,还是不通!!!就这样我又是reboot,又是shutdown,又是boot,还是不通,甚至连他提供的在线ssh连接工具也连接不上.<span id="more-681"></span></p>
<p>好吧我终于明白,网上的传说是真的,现在我只能发支持单,让他们的技术去解决吧,哥英文不好,不过写的估计他们也看得懂,就这样等了一天问题还是没有解决!没有人理我的支持单,于是哥就与他们的在线人员沟通,告知我他们的技术这会都忙,请我发一个邮件给他们,会处理的!!!这样就又等等了半天.</p>
<p>下午的时候,我忽然想起来他是可以重装系统了,在他们的后台找了半天,没有找到在哪里重装系统,再看他们给我发的开通邮件,原来管理链接发到我邮箱了,赶快登录上去,重新安装系统,再ping,通了,一切正常!</p>
<p>现在VPS使用两三天了,对他还不了解,但发现他是不太稳定,特别是网络,我在VPS上下载他们的测速链接,50M那个使用wget命令,最慢的时候下载速度只有114K(晚上11点了),今天又测试了一下,最快时达到了1.04M,可见网速很不稳定,一般快都称不上,我朋友那个传说垃圾中的战斗机BurstNet(burst)下载速度反而很快,至少有2M以上.</p>
<p>yardvps便宜,给的流量又大,但技术支持不好,别人没有空根本不会考虑帮助你,还可能会出一些想不到问题,速度也很不稳定(可能是一台服务器上的VPS太多了),CPU的核心也只有一个,所以真正想做网站的朋友还不不要考虑了.只推荐给入门学习的对稳定性不高又囊中羞涩的朋友,注意,这个是我个人的使用经验,不构成购买与购买建议.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.voland.com.cn/yardvps-troubles-during-the-trial/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

