<?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>PKILL.info &#187; java</title>
	<atom:link href="http://pkill.info/b/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://pkill.info/b</link>
	<description>Tutorials and tips</description>
	<lastBuildDate>Wed, 08 Sep 2010 06:08:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Hadoop Tutorial</title>
		<link>http://pkill.info/b/290/hadoop-tutorial/</link>
		<comments>http://pkill.info/b/290/hadoop-tutorial/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 09:48:37 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[Cloud Computing]]></category>
		<category><![CDATA[cloud computing]]></category>
		<category><![CDATA[hadoop]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[MapReduce]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/hadoop-tutorial/</guid>
		<description><![CDATA[How to set up hadoop environment in a small cluster that contains four machines is introduced in this tutorial. It is not hard to extend this system to a larger cluster just by adding slave nodes. 1. Install needed packages Sun Java JDK: Downloaded form: http://java.sun.com/ For example, it is installed into /usr/java/jdk1.6.0_16 which may [...]

<b>Read more:</b><ul><li><a href='http://pkill.info/b/699/mrcc-a-c-compiler-system-on-mapreduce/' rel='bookmark' title='Permanent Link: mrcc &#8211; A Distributed C Compiler System on MapReduce'>mrcc &#8211; A Distributed C Compiler System on MapReduce</a></li>
<li><a href='http://pkill.info/b/1419/vim-formatting-cc-code/' rel='bookmark' title='Permanent Link: Vim Formatting C/C++ Code'>Vim Formatting C/C++ Code</a></li>
<li><a href='http://pkill.info/b/240/generate-a-mixed-source-and-assembly-listing-using-gcc/' rel='bookmark' title='Permanent Link: Generate a mixed source and assembly list using gcc'>Generate a mixed source and assembly list using gcc</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>How to set up hadoop environment in a small cluster that contains four machines is introduced in this tutorial. It is not hard to extend this system to a larger cluster just by adding slave nodes.</p>
<h3>1. Install needed packages</h3>
<h4>Sun Java JDK:</h4>
<p>Downloaded form: http://java.sun.com/<br />
For example, it is installed into <em>/usr/java/jdk1.6.0_16</em> which may different depending on <em>jdk</em>&#8216;s version.</p>
<p>Install JDK on ALL nodes of the Hadoop cluster.</p>
<h4>Hadoop:</h4>
<p>Downloaded from: http://hadoop.apache.org/</p>
<p>Unpack it to somewhere. We store it in <em>/lhome/zma/hadoop</em> in this example</p>
<p>For our convenience that we needn&#8217;t to specify the full path when calling <em>hadoop</em>:</p>
<pre class="prettyprint">$ export PATH=/lhome/zma/hadoop-0.20.2/bin/:$PATH</pre>
<p>or</p>
<pre class="prettyprint">$ ln -s /lhome/zma/hadoop-0.20.2/bin/* /home/zma/bin/</pre>
<h3>2. Hosts files</h3>
<h4>Add lines like this to <em>/etc/hosts</em> on <strong>ALL</strong> nodes:</h4>
<p>We use four machines here.</p>
<pre class="prettyprint">10.0.0.103  vm103
10.0.0.104  vm104
10.0.0.105  vm105
10.0.0.106  vm106</pre>
<p>These host&#8217;s name will automatically change to the name described in the <em>hosts</em> file after rebooting.</p>
<h4>Configure <em>iptables</em>:</h4>
<p>We can configure <em>iptables</em> to allow all connections if these nodes are in a secure local area network by this command on all nodes:</p>
<pre class="prettyprint"># iptables -F
# service iptables save</pre>
<h3>3. Password-less SSH login</h3>
<p>More details about password-less ssh login can be found <a href="http://pkill.info/b/1500/enabling-password-less-ssh-login/" target="_blank">here</a>.</p>
<h4>Generate private and public key:</h4>
<p>On vm103 the master node:</p>
<pre class="prettyprint">$ ssh-keygen -t rsa
$ chmod 755 .ssh
$ cat .ssh/id_rsa.pub &gt;&gt; .ssh/authorized_keys
$ chmod 755 .ssh/authorized_keys</pre>
<h4>Copy .ssh directory to all nodes&#8217; home directories:</h4>
<pre class="prettyprint">$ for ((i=103; i&lt;=106; i++)); do scp -r .ssh vm$i:~/; done;</pre>
<h4>Try to ssh to all these nodes:</h4>
<pre class="prettyprint">$ for ((i=103; i&lt;=106; i++)); do ssh vm$i ; done;</pre>
<h3><strong>4. Hadoop Configurations</strong></h3>
<h4><em>hadoop/conf/hadoop-env.h</em></h4>
<p>Add or change these lines depending on your configuration:</p>
<pre class="prettyprint">export JAVA_HOME=/usr/java/jdk1.6.0_16
export HADOOP_HOME=/lhome/zma/hadoop-0.20.2</pre>
<h4>hadoop/conf/core-site.xml</h4>
<p>Add these lines:<br />
Here the <em>namenode</em> is vm103.</p>
<pre class="prettyprint">  &lt;property&gt;
    &lt;name&gt;fs.default.name&lt;/name&gt;
    &lt;value&gt;hdfs://vm103:9000&lt;/value&gt;
  &lt;/property&gt;</pre>
<h4><em>hadoop/conf/hdfs-site.xml</em></h4>
<p>Add these lines:</p>
<pre class="prettyprint">  &lt;property&gt;
    &lt;name&gt;dfs.replication&lt;/name&gt;
    &lt;value&gt;3&lt;/value&gt;
  &lt;/property&gt;</pre>
<h4><em>hadoop/conf/mapred-site.xml</em></h4>
<p>Add these lines:<br />
Here <em>jobtracker</em> is vm103.</p>
<pre class="prettyprint">&lt;property&gt;
    &lt;name&gt;mapred.job.tracker&lt;/name&gt;
    &lt;value&gt;vm103:9001&lt;/value&gt;
&lt;/property&gt;</pre>
<h4><em>hadoop/conf/masters</em></h4>
<p>Delete <em>localhost</em> and add:</p>
<pre class="prettyprint">vm103</pre>
<h4>hadoop/conf/slaves</h4>
<p>Delete <em>localhost</em> and add:</p>
<pre class="prettyprint">vm104
vm105
vm106</pre>
<h3><strong>5. Duplicate Hadoop to all nodes</strong></h3>
<p>Here we are on <em>vm103</em>:</p>
<pre class="prettyprint">$ for ((i=104; i&lt;=106; i++)); \
do scp -r /lhome/zma/hadoop vm$i:/lhome/zma/ ; \
done;</pre>
<h3><strong>6. Start Hadoop</strong></h3>
<p>We need to start both the HDFS and MapReduce to start Hadoop.</p>
<p>On vm103 (<em>namenode</em>):</p>
<h4>Format a new distributed-filesystem HDFS:</h4>
<pre class="prettyprint">$ hadoop namenode -format</pre>
<p>Remember to delete HDFS&#8217;s local files on all nodes before reformat it:</p>
<pre class="prettyprint">$ rm /lhome/zma/hadoop/logs /tmp/hadoop-zma -rf</pre>
<h4>Start HDFS:</h4>
<pre class="prettyprint">$ start-dfs.sh</pre>
<h4>Check the HDFS status:</h4>
<pre class="prettyprint">$ hadoop dfsadmin -report</pre>
<p>There may be less nodes listed in the report than we actually have. We can try it again.</p>
<h4>Start mpared:</h4>
<p>On vm103 (<em>jobtracker</em>):</p>
<pre class="prettyprint">$ start-mapred.sh</pre>
<h4>Check job status:</h4>
<pre class="prettyprint">$ hadoop job -list</pre>
<h3><strong>7. Enjoy the fun now</strong></h3>
<h4>A simple example</h4>
<p>Copy the input files into the distributed filesystem:</p>
<pre class="prettyprint">$ hadoop fs -put hadoop-0.20.2/conf input</pre>
<p>Run some of the examples provided:</p>
<pre class="prettyprint">$ cd hadoop-0.20.2
$ hadoop jar hadoop-0.20.2-examples.jar grep input output 'dfs[a-z.]+'</pre>
<p>Examine the output files:</p>
<p>Copy the output files from the distributed filesystem to the local<br />
filesytem and examine them:</p>
<pre class="prettyprint">$ hadoop dfs -get output output
$ cat output/*</pre>
<p>or</p>
<p>View the output files on the distributed filesystem:</p>
<pre class="prettyprint">$ hadoop dfs -cat output/*</pre>
<h3>8. Shut down Hadoop cluster<strong><br />
</strong></h3>
<pre class="prettyprint">$ stop-dfs.sh
$ stop-mapred.sh</pre>
<p>or simply stop bothe DFS and MapReduce in one command:</p>
<pre class="prettyprint">$ stop-all.sh</pre>
<h3>References</h3>
<p>[1] http://hadoop.apache.org/common/docs/current/quickstart.html</p>
<p><span style="font-size: x-small;"><strong>Updated history</strong><br />
Feb. 23, 2010. Format this post.<br />
May. 1, 2010. Change the part that copy .ssh directory to all machines.<br />
Jun. 30, 2010. Format the post.<br />
Jul. 13, 2010. Revise the article. The jobtracker and namenode can be same master machine.<br />
Jul. 14, 2010. Add iptables configuration commands.</span></p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/699/mrcc-a-c-compiler-system-on-mapreduce/' rel='bookmark' title='Permanent Link: mrcc &#8211; A Distributed C Compiler System on MapReduce'>mrcc &#8211; A Distributed C Compiler System on MapReduce</a></li>
<li><a href='http://pkill.info/b/1419/vim-formatting-cc-code/' rel='bookmark' title='Permanent Link: Vim Formatting C/C++ Code'>Vim Formatting C/C++ Code</a></li>
<li><a href='http://pkill.info/b/240/generate-a-mixed-source-and-assembly-listing-using-gcc/' rel='bookmark' title='Permanent Link: Generate a mixed source and assembly list using gcc'>Generate a mixed source and assembly list using gcc</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/290/hadoop-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A C++/Java programmer&#8217;s introduction to Objective Caml</title>
		<link>http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/</link>
		<comments>http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 07:50:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming.ocaml]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/a-cjava-programmers-introduction-to-objective-caml/</guid>
		<description><![CDATA[A very very good introduction to OCaml: A C++/Java programmer&#8217;s introduction to Objective Caml Read more:Java与C++在语言方面上的不同 Vim Formatting C/C++ Code The C Programming Style that I Follow

<b>Read more:</b><ul><li><a href='http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/' rel='bookmark' title='Permanent Link: Java与C++在语言方面上的不同'>Java与C++在语言方面上的不同</a></li>
<li><a href='http://pkill.info/b/1419/vim-formatting-cc-code/' rel='bookmark' title='Permanent Link: Vim Formatting C/C++ Code'>Vim Formatting C/C++ Code</a></li>
<li><a href='http://pkill.info/b/1352/the-c-programming-style-that-i-follow/' rel='bookmark' title='Permanent Link: The C Programming Style that I Follow'>The C Programming Style that I Follow</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>A very very good introduction to OCaml:</p>
<p><a href="http://caml.inria.fr/pub/old_caml_site/FAQ/stephan.html">A C++/Java programmer&#8217;s introduction to Objective Caml</a></p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/' rel='bookmark' title='Permanent Link: Java与C++在语言方面上的不同'>Java与C++在语言方面上的不同</a></li>
<li><a href='http://pkill.info/b/1419/vim-formatting-cc-code/' rel='bookmark' title='Permanent Link: Vim Formatting C/C++ Code'>Vim Formatting C/C++ Code</a></li>
<li><a href='http://pkill.info/b/1352/the-c-programming-style-that-i-follow/' rel='bookmark' title='Permanent Link: The C Programming Style that I Follow'>The C Programming Style that I Follow</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>一个基于Java Applet的浏览器端远程系统资源监视器</title>
		<link>http://pkill.info/b/380/%e4%b8%80%e4%b8%aa%e5%9f%ba%e4%ba%8ejava-applet%e7%9a%84%e6%b5%8f%e8%a7%88%e5%99%a8%e7%ab%af%e8%bf%9c%e7%a8%8b%e7%b3%bb%e7%bb%9f%e8%b5%84%e6%ba%90%e7%9b%91%e8%a7%86%e5%99%a8-2/</link>
		<comments>http://pkill.info/b/380/%e4%b8%80%e4%b8%aa%e5%9f%ba%e4%ba%8ejava-applet%e7%9a%84%e6%b5%8f%e8%a7%88%e5%99%a8%e7%ab%af%e8%bf%9c%e7%a8%8b%e7%b3%bb%e7%bb%9f%e8%b5%84%e6%ba%90%e7%9b%91%e8%a7%86%e5%99%a8-2/#comments</comments>
		<pubDate>Thu, 29 Jan 2009 19:40:45 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[Project]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/%e4%b8%80%e4%b8%aa%e5%9f%ba%e4%ba%8ejava-applet%e7%9a%84%e6%b5%8f%e8%a7%88%e5%99%a8%e7%ab%af%e8%bf%9c%e7%a8%8b%e7%b3%bb%e7%bb%9f%e8%b5%84%e6%ba%90%e7%9b%91%e8%a7%86%e5%99%a8-2/</guid>
		<description><![CDATA[一个基于Java Applet的浏览器端远程系统资源监视器，使用Socket从网络主机上读取信息然后在browser上动态显示出来。 这个演示程序中使用的是正态分布生成的数据。 截图一张： Read more:A C++/Java programmer&#8217;s introduction to Objective Caml SetProxy 一个设置IE代理的小工具 DebugTerm &#8211; telnet二进制显示与发送调试程序

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/386/setproxy-%e4%b8%80%e4%b8%aa%e8%ae%be%e7%bd%aeie%e4%bb%a3%e7%90%86%e7%9a%84%e5%b0%8f%e5%b7%a5%e5%85%b7/' rel='bookmark' title='Permanent Link: SetProxy 一个设置IE代理的小工具'>SetProxy 一个设置IE代理的小工具</a></li>
<li><a href='http://pkill.info/b/383/debugterm-telnet%e4%ba%8c%e8%bf%9b%e5%88%b6%e6%98%be%e7%a4%ba%e4%b8%8e%e5%8f%91%e9%80%81%e8%b0%83%e8%af%95%e7%a8%8b%e5%ba%8f/' rel='bookmark' title='Permanent Link: DebugTerm &#8211; telnet二进制显示与发送调试程序'>DebugTerm &#8211; telnet二进制显示与发送调试程序</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>一个基于Java Applet的浏览器端远程系统资源监视器，使用Socket从网络主机上读取信息然后在browser上动态显示出来。<br />
这个演示程序中使用的是正态分布生成的数据。</p>
<p>截图一张：<br />
<a href="http://picasaweb.google.com/qiang.z.m/Pro/photo#5192483611096640338"><img src="http://lh4.ggpht.com/qiang.z.m/SA9oVVVz61I/AAAAAAAAALg/VUFYxqxYUPY/s144/GraphicsCharDemo.png" alt="" /></a></p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/386/setproxy-%e4%b8%80%e4%b8%aa%e8%ae%be%e7%bd%aeie%e4%bb%a3%e7%90%86%e7%9a%84%e5%b0%8f%e5%b7%a5%e5%85%b7/' rel='bookmark' title='Permanent Link: SetProxy 一个设置IE代理的小工具'>SetProxy 一个设置IE代理的小工具</a></li>
<li><a href='http://pkill.info/b/383/debugterm-telnet%e4%ba%8c%e8%bf%9b%e5%88%b6%e6%98%be%e7%a4%ba%e4%b8%8e%e5%8f%91%e9%80%81%e8%b0%83%e8%af%95%e7%a8%8b%e5%ba%8f/' rel='bookmark' title='Permanent Link: DebugTerm &#8211; telnet二进制显示与发送调试程序'>DebugTerm &#8211; telnet二进制显示与发送调试程序</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/380/%e4%b8%80%e4%b8%aa%e5%9f%ba%e4%ba%8ejava-applet%e7%9a%84%e6%b5%8f%e8%a7%88%e5%99%a8%e7%ab%af%e8%bf%9c%e7%a8%8b%e7%b3%bb%e7%bb%9f%e8%b5%84%e6%ba%90%e7%9b%91%e8%a7%86%e5%99%a8-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSP连接MySQL</title>
		<link>http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/</link>
		<comments>http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:37:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/jsp%e8%bf%9e%e6%8e%a5mysql/</guid>
		<description><![CDATA[1) 将下载到的驱动mysql-connector-java-5.1.6-bin.jar复制到WEB-INF/lib/下,记得更新启动tomcat2) 使用范例 //驱动程序名String driverName=&#8221;com.mysql.jdbc.Driver&#8221;; //数据库用户名String userName=&#8221;username&#8221;; //密码String userPasswd=&#8221;password&#8221;; //数据库名String dbName=&#8221;dbname&#8221;; //表名String tableName=&#8221;tablename&#8221;; //联结字符串String url=&#8221;jdbc:mysql://localhost/&#8221;+dbName+&#8221;?user=&#8221;+userName+&#8221;&#38;password=&#8221;+userPasswd; Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;).newInstance();Connection conn=DriverManager.getConnection(url);Statement statement = conn.createStatement();String sql=&#8221;SELECT * FROM &#8220;+tableName;ResultSet rs = statement.executeQuery(sql); //获得数据结果集合ResultSetMetaData rmeta = rs.getMetaData(); //确定数据集的列数，亦字段数int numColumns=rmeta.getColumnCount(); // 输出每一个数据值while(rs.next()) { out.print(rs.getString(1)+&#8221; &#8220;); out.print(&#8220;&#124;&#8221;); out.print(rs.getString(2)); out.print(&#8220;&#8220;);} out.print(&#8220;&#8220;);out.print(&#8220;数据库操作成功，恭喜你&#8221;);rs.close(); statement.close();conn.close(); Read more:Java中调用本地代码 Java中控制符的作用范围 Java与C++在语言方面上的不同

<b>Read more:</b><ul><li><a href='http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/' rel='bookmark' title='Permanent Link: Java中调用本地代码'>Java中调用本地代码</a></li>
<li><a href='http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/' rel='bookmark' title='Permanent Link: Java中控制符的作用范围'>Java中控制符的作用范围</a></li>
<li><a href='http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/' rel='bookmark' title='Permanent Link: Java与C++在语言方面上的不同'>Java与C++在语言方面上的不同</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>1) 将下载到的驱动mysql-connector-java-5.1.6-bin.jar复制到WEB-INF/lib/下,记得更新启动tomcat<br />2) 使用范例</p>
<p>//驱动程序名<br />String driverName=&#8221;com.mysql.jdbc.Driver&#8221;;</p>
<p>//数据库用户名<br />String userName=&#8221;username&#8221;;</p>
<p>//密码<br />String userPasswd=&#8221;password&#8221;;</p>
<p>//数据库名<br />String dbName=&#8221;dbname&#8221;;</p>
<p>//表名<br />String tableName=&#8221;tablename&#8221;;</p>
<p>//联结字符串<br />String url=&#8221;jdbc:mysql://localhost/&#8221;+dbName+&#8221;?user=&#8221;+userName+&#8221;&amp;password=&#8221;+userPasswd;</p>
<p>Class.forName(&#8220;com.mysql.jdbc.Driver&#8221;).newInstance();<br />Connection conn=DriverManager.getConnection(url);<br />Statement statement = conn.createStatement();<br />String sql=&#8221;SELECT * FROM &#8220;+tableName;<br />ResultSet rs = statement.executeQuery(sql);</p>
<p>//获得数据结果集合<br />ResultSetMetaData rmeta = rs.getMetaData();</p>
<p>//确定数据集的列数，亦字段数<br />int numColumns=rmeta.getColumnCount();</p>
<p>// 输出每一个数据值<br />while(rs.next()) {<br />    out.print(rs.getString(1)+&#8221; &#8220;);<br />    out.print(&#8220;|&#8221;);<br />    out.print(rs.getString(2));<br />    out.print(&#8220;<br />&#8220;);<br />}</p>
<p>out.print(&#8220;<br />&#8220;);<br />out.print(&#8220;数据库操作成功，恭喜你&#8221;);<br />rs.close();</p>
<p>statement.close();<br />conn.close();</p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/' rel='bookmark' title='Permanent Link: Java中调用本地代码'>Java中调用本地代码</a></li>
<li><a href='http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/' rel='bookmark' title='Permanent Link: Java中控制符的作用范围'>Java中控制符的作用范围</a></li>
<li><a href='http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/' rel='bookmark' title='Permanent Link: Java与C++在语言方面上的不同'>Java与C++在语言方面上的不同</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java中调用本地代码</title>
		<link>http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/</link>
		<comments>http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:36:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/</guid>
		<description><![CDATA[Java中调用.dll中本地代码方法介绍: 环境: Microsoft Windows XP [版本 5.1.2600] (C) 版权所有 1985-2001 Microsoft Corp. JDK: C:\Documents and Settings\mzq&#62;java -version java version &#8220;1.6.0_05&#8243; Java(TM) SE Runtime Environment (build 1.6.0_05-b13) Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing) 本地代码编译环境: MS Visual Studio 2008 1) 编写Java代码 示例代码如下: public class JNITest { public static void main (String args[]) { if [...]

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/' rel='bookmark' title='Permanent Link: JSP连接MySQL'>JSP连接MySQL</a></li>
<li><a href='http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/' rel='bookmark' title='Permanent Link: Java中控制符的作用范围'>Java中控制符的作用范围</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Java中调用.dll中本地代码方法介绍:</p>
<p>环境:<br />
Microsoft Windows XP [版本 5.1.2600]<br />
(C) 版权所有 1985-2001 Microsoft Corp.</p>
<p>JDK:<br />
C:\Documents and Settings\mzq&gt;java -version<br />
java version &#8220;1.6.0_05&#8243;<br />
Java(TM) SE Runtime Environment (build 1.6.0_05-b13)<br />
Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)</p>
<p>本地代码编译环境:<br />
MS Visual Studio 2008</p>
<p>1) 编写Java代码<br />
示例代码如下:</p>
<pre>public class JNITest {
public static void main (String args[]) {
  if (args.length &gt; 0) {
    int x = new Integer(args[0]).intValue();
    int a = new mynative().cubecal(x);
    System.out.println(a);
  }
}
}

class mynative {
public native int cubecal(int x);
static {
  System.loadLibrary("mynative");
}
}</pre>
<p>注意mynative类内容即可.</p>
<p>2)生成为本地方法调用的mynative.h头文件</p>
<p>D:\workspace_java\JNI\src&gt;javac JNITest.java</p>
<p>D:\workspace_java\JNI\src&gt;javah -jni mynative</p>
<p>3)编写本地代码<br />
注意:代码扩展名一定要用.c</p>
<p>根据mynative.h编写</p>
<pre>#include "jni.h"

int cube(int x) {
return (x*x*x);
}

JNIEXPORT jint JNICALL Java_mynative_cubecal
(JNIEnv *e, jobject o, jint x) {
return cube(x);
}</pre>
<p>4)解决依赖关系<br />
将$JAVA_HOME$/include/jni.h      $JAVA_HOME$/include/win32/jni_md.h<br />
及mynative.h复制到vs2008 proj目录下</p>
<p>5)编译生成mynative.dll</p>
<p>6)复制mynative.dll到存放Java项目目录中运行即可</p>
<p>D:\workspace_java\JNI\bin 的目录</p>
<p>2008-06-02  14:52               413 mynative.class<br />
2008-06-02  14:52               719 JNITest.class<br />
2008-06-02  15:39             7,168 mynative.dll<br />
3 个文件          8,300 字节<br />
2 个目录  7,816,396,800 可用字节</p>
<p>D:\workspace_java\JNI\bin&gt;java JNITest 9<br />
729</p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/' rel='bookmark' title='Permanent Link: JSP连接MySQL'>JSP连接MySQL</a></li>
<li><a href='http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/' rel='bookmark' title='Permanent Link: Java中控制符的作用范围'>Java中控制符的作用范围</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java中控制符的作用范围</title>
		<link>http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/</link>
		<comments>http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:35:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/</guid>
		<description><![CDATA[描述 private 默认 protected public private protected 同一类中可见 Y Y Y Y Y 同一包中子类可见 N Y Y Y Y 同一包中非子类可见 N Y Y Y N 不同包中子类可见 N N Y Y Y 不同包中对非子类可见 N N N Y N Read more:A C++/Java programmer&#8217;s introduction to Objective Caml JSP连接MySQL Java中调用本地代码

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/' rel='bookmark' title='Permanent Link: JSP连接MySQL'>JSP连接MySQL</a></li>
<li><a href='http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/' rel='bookmark' title='Permanent Link: Java中调用本地代码'>Java中调用本地代码</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<table border="1">
<tbody>
<tr>
<td>描述</td>
<td>private</td>
<td>默认</td>
<td>protected</td>
<th>public</th>
<td>private protected</td>
</tr>
<p>
<tr>
<td>同一类中可见</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
</tr>
<tr>
<td>同一包中子类可见</td>
<td>N</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
</tr>
<tr>
<td>同一包中非子类可见</td>
<td>N</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
<td>N</td>
</tr>
<tr>
<td>不同包中子类可见</td>
<td>N</td>
<td>N</td>
<td>Y</td>
<td>Y</td>
<td>Y</td>
</tr>
<tr>
<td>不同包中对非子类可见</td>
<td>N</td>
<td>N</td>
<td>N</td>
<td>Y</td>
<td>N</td>
</tr>
<p></tbody>
</table>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/' rel='bookmark' title='Permanent Link: JSP连接MySQL'>JSP连接MySQL</a></li>
<li><a href='http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/' rel='bookmark' title='Permanent Link: Java中调用本地代码'>Java中调用本地代码</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/88/java%e4%b8%ad%e6%8e%a7%e5%88%b6%e7%ac%a6%e7%9a%84%e4%bd%9c%e7%94%a8%e8%8c%83%e5%9b%b4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java中的数据类型</title>
		<link>http://pkill.info/b/85/java%e4%b8%ad%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b/</link>
		<comments>http://pkill.info/b/85/java%e4%b8%ad%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:34:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/java%e4%b8%ad%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b/</guid>
		<description><![CDATA[Java中有两种数据类型：基本数据类型，引用数据类型。 基本数据类型的长度和范围： 类型 长度 范围 byte 1 -128~127 short 2 -32,768~32,767 int 4 -2,147,483,648~2,147,483,647 long 8 -9,223,372,036,854,775,808~9,223,372,036,854,775,807 float 4 about +/-3.40282347E＋38F double 8 about +/- 1.79769313486231570E+308 char 2 boolean - true/false Read more:A C++/Java programmer&#8217;s introduction to Objective Caml JSP连接MySQL Java中调用本地代码

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/' rel='bookmark' title='Permanent Link: JSP连接MySQL'>JSP连接MySQL</a></li>
<li><a href='http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/' rel='bookmark' title='Permanent Link: Java中调用本地代码'>Java中调用本地代码</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>Java中有两种数据类型：基本数据类型，引用数据类型。</p>
<p>基本数据类型的长度和范围：</p>
<table>
<tbody>
<tr>
<td>类型</td>
<td>长度</td>
<td>范围</td>
<p></tr>
<p>
<tr>
<td>byte</td>
<td>1</td>
<td>-128~127</td>
<p></tr>
<p>
<tr>
<td>short</td>
<td>2</td>
<td>-32,768~32,767</td>
<p></tr>
<p>
<tr>
<td>int</td>
<td>4</td>
<td>-2,147,483,648~2,147,483,647</td>
<p></tr>
<p>
<tr>
<td>long</td>
<td>8</td>
<td>-9,223,372,036,854,775,808~9,223,372,036,854,775,807</td>
<p></tr>
<p>
<tr>
<td>float</td>
<td>4</td>
<td>about +/-3.40282347E＋38F</td>
<p></tr>
<p>
<tr>
<td>double</td>
<td>8</td>
<td>about +/- 1.79769313486231570E+308</td>
<p></tr>
<p>
<tr>
<td>char</td>
<td>2</td>
<td></td>
<p></tr>
<p>
<tr>
<td>boolean</td>
<td>-</td>
<td>true/false</td>
<p></tr>
</tbody>
<p></table>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/91/jsp%e8%bf%9e%e6%8e%a5mysql/' rel='bookmark' title='Permanent Link: JSP连接MySQL'>JSP连接MySQL</a></li>
<li><a href='http://pkill.info/b/89/java%e4%b8%ad%e8%b0%83%e7%94%a8%e6%9c%ac%e5%9c%b0%e4%bb%a3%e7%a0%81/' rel='bookmark' title='Permanent Link: Java中调用本地代码'>Java中调用本地代码</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/85/java%e4%b8%ad%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java与C++在语言方面上的不同</title>
		<link>http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/</link>
		<comments>http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:34:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/</guid>
		<description><![CDATA[1，Java抛弃了头文件、预处理机制、goto语句和多维数组。2，Java不支持指针。3，Java抛弃了联合体和结构体。4，Java不支持独立函数。所有函数必须在类中声明。5，Java不支持多重继承，可以使用接口模拟多重继承。6，Java不支持运算符重载。7，Java中布尔型不再用整数来代替。8，Java中主函数必须有一个字符串类型的参数。 Java抛弃的C++中的这些机制和结构多数都是“危险”的，减少了语言的复杂性，增强了安全性，虽然在一定程度上减少了其灵活性。 Read more:A C++/Java programmer&#8217;s introduction to Objective Caml Vim Formatting C/C++ Code The C Programming Style that I Follow

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/1419/vim-formatting-cc-code/' rel='bookmark' title='Permanent Link: Vim Formatting C/C++ Code'>Vim Formatting C/C++ Code</a></li>
<li><a href='http://pkill.info/b/1352/the-c-programming-style-that-i-follow/' rel='bookmark' title='Permanent Link: The C Programming Style that I Follow'>The C Programming Style that I Follow</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>1，Java抛弃了头文件、预处理机制、goto语句和多维数组。<br />2，Java不支持指针。<br />3，Java抛弃了联合体和结构体。<br />4，Java不支持独立函数。所有函数必须在类中声明。<br />5，Java不支持多重继承，可以使用接口模拟多重继承。<br />6，Java不支持运算符重载。<br />7，Java中布尔型不再用整数来代替。<br />8，Java中主函数必须有一个字符串类型的参数。</p>
<p>Java抛弃的C++中的这些机制和结构多数都是“危险”的，减少了语言的复杂性，增强了安全性，虽然在一定程度上减少了其灵活性。</p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/1419/vim-formatting-cc-code/' rel='bookmark' title='Permanent Link: Vim Formatting C/C++ Code'>Vim Formatting C/C++ Code</a></li>
<li><a href='http://pkill.info/b/1352/the-c-programming-style-that-i-follow/' rel='bookmark' title='Permanent Link: The C Programming Style that I Follow'>The C Programming Style that I Follow</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/86/java%e4%b8%8ec%e5%9c%a8%e8%af%ad%e8%a8%80%e6%96%b9%e9%9d%a2%e4%b8%8a%e7%9a%84%e4%b8%8d%e5%90%8c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>linux中Java环境变量设置</title>
		<link>http://pkill.info/b/71/linux%e4%b8%adjava%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e8%ae%be%e7%bd%ae/</link>
		<comments>http://pkill.info/b/71/linux%e4%b8%adjava%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e8%ae%be%e7%bd%ae/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:21:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[client config]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[server config]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/linux%e4%b8%adjava%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e8%ae%be%e7%bd%ae/</guid>
		<description><![CDATA[安装完java的程序包之后要使用java还需要设置相应的环境变量。主要有三个：JAVA_HOME, CLASSPATH, PATH 相应设置方法如下： 在/etc/profile.d/下建立一脚本java.sh用来设置环境变量。在脚本中export这三个环境变量 下面列出我的java.sh，不同版本设置方法类似。 #/etc/profile.d/java.sh &#8212; set java environment export JAVA_HOME=/usr/java/jdk1.6.0_04export CLASSPATH=.:/usr/java/jdk1.6.0_04/lib:/usr/java/jdk1.6.0_04/jre/libexport PATH=/usr/java/jdk1.6.0_04/bin:/usr/java/jdk1.6.0_04/jre/bin:$PATH 之后分配java.sh权限：chmod 755 /etc/profile.d/java.sh 手动运行一次java.sh或重新启动linux后就可以使用了。运行 java -version 如果正常显示版本信息就OK了。 类似如下： [mzq@mzq ~]$ java -versionjava version &#8220;1.6.0_04&#8243;Java(TM) SE Runtime Environment (build 1.6.0_04-b12)Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing) Read more:A C++/Java programmer&#8217;s introduction to Objective Caml Setting up eCryptFS in Linux [...]

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/1638/setting-up-ecryptfs-in-linux/' rel='bookmark' title='Permanent Link: Setting up eCryptFS in Linux'>Setting up eCryptFS in Linux</a></li>
<li><a href='http://pkill.info/b/223/add-more-loop-device-on-linux/' rel='bookmark' title='Permanent Link: Add more loop device on Linux'>Add more loop device on Linux</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>安装完java的程序包之后要使用java还需要设置相应的环境变量。<br />主要有三个：<br />JAVA_HOME, CLASSPATH, PATH</p>
<p>相应设置方法如下：</p>
<p>在/etc/profile.d/下建立一脚本java.sh用来设置环境变量。<br />在脚本中export这三个环境变量</p>
<p>下面列出我的java.sh，不同版本设置方法类似。</p>
<p>#/etc/profile.d/java.sh &#8212; set java environment</p>
<p>export JAVA_HOME=/usr/java/jdk1.6.0_04<br />export CLASSPATH=.:/usr/java/jdk1.6.0_04/lib:/usr/java/jdk1.6.0_04/jre/lib<br />export PATH=/usr/java/jdk1.6.0_04/bin:/usr/java/jdk1.6.0_04/jre/bin:$PATH</p>
<p>之后分配java.sh权限：<br />chmod 755 /etc/profile.d/java.sh</p>
<p>手动运行一次java.sh或重新启动linux后就可以使用了。<br />运行 java -version 如果正常显示版本信息就OK了。</p>
<p>类似如下：</p>
<p>[mzq@mzq ~]$ java -version<br />java version &#8220;1.6.0_04&#8243;<br />Java(TM) SE Runtime Environment (build 1.6.0_04-b12)<br />Java HotSpot(TM) Client VM (build 10.0-b19, mixed mode, sharing)</p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/1638/setting-up-ecryptfs-in-linux/' rel='bookmark' title='Permanent Link: Setting up eCryptFS in Linux'>Setting up eCryptFS in Linux</a></li>
<li><a href='http://pkill.info/b/223/add-more-loop-device-on-linux/' rel='bookmark' title='Permanent Link: Add more loop device on Linux'>Add more loop device on Linux</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/71/linux%e4%b8%adjava%e7%8e%af%e5%a2%83%e5%8f%98%e9%87%8f%e8%ae%be%e7%bd%ae/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux中Java 中文字体乱码解决</title>
		<link>http://pkill.info/b/58/java-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e4%b9%b1%e7%a0%81%e8%a7%a3%e5%86%b3/</link>
		<comments>http://pkill.info/b/58/java-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e4%b9%b1%e7%a0%81%e8%a7%a3%e5%86%b3/#comments</comments>
		<pubDate>Sat, 16 Aug 2008 05:11:00 +0000</pubDate>
		<dc:creator>Zhiqiang Ma</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[client config]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[中文]]></category>

		<guid isPermaLink="false">http://zhiqiangma.info/java-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e4%b9%b1%e7%a0%81%e8%a7%a3%e5%86%b3/</guid>
		<description><![CDATA[是没有相应中文字体的原因。 设置如下： [root@localhost fonts]# mkdir fallback[root@localhost fonts]# cd fallback/[root@localhost fallback]# pwd/usr/java/jdk1.6.0_05/jre/lib/fonts/fallback[root@localhost fallback]# ln -s /usr/share/fonts/zh_CN/TrueType/zysong.ttf Read more:A C++/Java programmer&#8217;s introduction to Objective Caml Setting up eCryptFS in Linux Speeding up Firefox on Linux

<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/1638/setting-up-ecryptfs-in-linux/' rel='bookmark' title='Permanent Link: Setting up eCryptFS in Linux'>Setting up eCryptFS in Linux</a></li>
<li><a href='http://pkill.info/b/1596/speeding-up-firefox-on-linux/' rel='bookmark' title='Permanent Link: Speeding up Firefox on Linux'>Speeding up Firefox on Linux</a></li>
</ul>]]></description>
			<content:encoded><![CDATA[<p>是没有相应中文字体的原因。</p>
<p>设置如下：</p>
<p>[root@localhost fonts]# mkdir fallback<br />[root@localhost fonts]# cd fallback/<br />[root@localhost fallback]# pwd<br />/usr/java/jdk1.6.0_05/jre/lib/fonts/fallback<br />[root@localhost fallback]# ln -s /usr/share/fonts/zh_CN/TrueType/zysong.ttf</p>


<b>Read more:</b><ul><li><a href='http://pkill.info/b/135/a-cjava-programmers-introduction-to-objective-caml/' rel='bookmark' title='Permanent Link: A C++/Java programmer&#8217;s introduction to Objective Caml'>A C++/Java programmer&#8217;s introduction to Objective Caml</a></li>
<li><a href='http://pkill.info/b/1638/setting-up-ecryptfs-in-linux/' rel='bookmark' title='Permanent Link: Setting up eCryptFS in Linux'>Setting up eCryptFS in Linux</a></li>
<li><a href='http://pkill.info/b/1596/speeding-up-firefox-on-linux/' rel='bookmark' title='Permanent Link: Speeding up Firefox on Linux'>Speeding up Firefox on Linux</a></li>
</ul>]]></content:encoded>
			<wfw:commentRss>http://pkill.info/b/58/java-%e4%b8%ad%e6%96%87%e5%ad%97%e4%bd%93%e4%b9%b1%e7%a0%81%e8%a7%a3%e5%86%b3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
