<?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>CertPal &#187; java</title>
	<atom:link href="http://www.certpal.com/blogs/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.certpal.com/blogs</link>
	<description>Technology and certifications</description>
	<lastBuildDate>Mon, 26 Jul 2010 17:34:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Java Neuroph tutorial &#8211; The code classifier</title>
		<link>http://www.certpal.com/blogs/2010/07/java-neuroph-tutorial-the-code-classifier/</link>
		<comments>http://www.certpal.com/blogs/2010/07/java-neuroph-tutorial-the-code-classifier/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 17:34:59 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[neural]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=844</guid>
		<description><![CDATA[The Neuroph API can be used to train neural networks in java. This experiment tries to use the API to enable automatic classification of source code based on the programming language it belongs to]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F07%2Fjava-neuroph-tutorial-the-code-classifier%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F07%2Fjava-neuroph-tutorial-the-code-classifier%2F" height="61" width="51" /></a></div><p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_logo.png"><img class="alignright size-full wp-image-666" title="neuroph_logo" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_logo.png" alt="" width="257" height="148" /></a> An <a href="http://www.ibm.com/developerworks/library/l-neural/" target="_blank">article was written a while back</a> about how neural networks can be used to classify source code. Yes the source code that you write to feed to compilers / interpreters.</p>
<p>The article explains at a high level what method could be used to perform this activity. In the end the author claims some level of success and wonders how other neural-network implementations / techniques would solve the same problem. This got me curious enough and I spent a weekend trying to crack this with Neuroph, the neural network library for java. I present to you my analysis and results below. For the impatient here is the code-classifier <a href="http://www.certpal.com/NeuralWeb/index.html" target="_blank">DEMO</a>.</p>
<h2>Why solve this problem with neural networks ?</h2>
<p>So where do we begin ? How about the question &#8216;Why do we need neural networks to solve this problem ?&#8217;. Well actually it might not be the &#8216;best&#8217; way to solve the problem. A lexer is a better solution to this problem since it can scan the source file and probably give you a much better accuracy on the clasification. But neural networks are also great for this problem since they can keep learning based on the input that is provided. Add one more programming language into the bag and the network can learn about this language without a programmer needing to type extra code into a lexer.</p>
<h2>So how do we do it ?</h2>
<p>One of the features that differentiates one source code type from another is the keywords used by the programming language in question. So lets target that. Our neural network will try to identify if source code belongs to the java language or the python language. </p>
<p>It takes as its input a list of all keywords available in both languages. Mind you that there may even be some overlap between the keywords. For example the keyword &#8216;if&#8217; is used in both languages. But there may be keywords that are used solely in one language alone.</p>
<p><strong>Neural network viewed in graph mode: (The network is too huge to fit into this picture <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )<br />
</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/neural_code_classifier.png"><img class="aligncenter size-full wp-image-848" title="neural_code_classifier" src="http://www.certpal.com/blogs/wp-content/uploads/neural_code_classifier.png" alt="" width="738" height="552" /></a></p>
<p>A middle layer will contain a few nodes that will back propagate anything that it learns. The output layer (just one node) will decide if the language is java / python. The value will range from 0-1, where 0 represents closeness to python and 1 represents closeness to java.</p>
<h2>How do we train it ?</h2>
<p>The process of training is made easy by the neuroph API. First we need a few java / python files. A program was written that reads each file and splits it based on the whitespace delimiter. Based on a known set of keywords, the network is fed the number of times a keyword appears in a source file.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span>Map<span style="color: #339933;">&lt;</span>Double, Double<span style="color: #339933;">&gt;</span> map <span style="color: #339933;">:</span> keywordStrength<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    Collection<span style="color: #339933;">&lt;</span>Double<span style="color: #339933;">&gt;</span> values <span style="color: #339933;">=</span> map.<span style="color: #006633;">values</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Vector<span style="color: #339933;">&lt;</span>Double<span style="color: #339933;">&gt;</span> input <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Vector<span style="color: #339933;">&lt;</span>Double<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    input.<span style="color: #006633;">addAll</span><span style="color: #009900;">&#40;</span>values<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    SupervisedTrainingElement supervisedTrainingElement <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> SupervisedTrainingElement<span style="color: #009900;">&#40;</span>input,output<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    trainingSet.<span style="color: #006633;">addElement</span><span style="color: #009900;">&#40;</span>supervisedTrainingElement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>For example, recognized keywords may be &#8216;public&#8217; represented by the input index 0 and &#8216;static&#8217; represented by the input index 1.  A java file may contain the word pubic 10 times and static 5 times. The input to the network in this case would be 10 5. We can now use these numbers to tell the network &#8216;Hey if you see this pattern it is likely that the source code belongs to language X&#8217;. Neat !. Once the network is trained you can load it and use the same process to classify source code for any given input String.</p>
<h2>Well&#8230; show us some stats:</h2>
<p>Before I say anything else, I did not expect this approach to succeed more than 10-20% of the time. This is because the number of files that I trained this network with was around 20. Java + Python included. But I was surprised to see the network classifying the data correctly most of the time. There were very few cases where it failed.</p>
<p>The real test for this network is now in your hands. I made a java web app on top of this &#8216;code classifier&#8217; application and built a simple UI using Jquery. You can type in any code / junk you want and hit the trained network. If it manages to classify your code correctly at least 60% of the time, I would consider that an enormous victory (for Neuroph ?) <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>So what are you waiting for, <a href="http://www.certpal.com/NeuralWeb/index.html" target="_blank">take her for a spin</a>.</p>
<h2>How do I game the results:</h2>
<p>This is pretty simple. There are certain rules you must follow. Not following them will give you weird results <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>1. Make sure that your code does not contain comments. I do not strip comments from code before analyzing them for keywords. Including java like keywords in a python file comment will confuse the network.<br />
2. Input only those files that will compile / run correctly on Java / Python. In theory you could feed in a Shakespeare novel to my network and it will still try to classify it as source code <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So does the network work for you ? Feel free to leave a comment.</p>
<p><em>I also wrote a simpler <a href="http://www.certpal.com/blogs/2010/04/java-neural-networks-and-neuroph-a-tutorial/" target="_new">tutorial for Neuroph</a> that is less practical and more academic. Check it out if it interests you</em></p>
<p><script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/07/java-neuroph-tutorial-the-code-classifier/';</script><br />
<script type="text/javascript">var dzone_title = 'Java Neuroph tutorial - The code classifier';</script><br />
<script type="text/javascript">var dzone_blurb = 'The Neuroph API can be used to train neural networks in java. This experiment tries to use the API to enable automatic classification of source code based on the programming language it belongs to. ';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F07%2Fjava-neuroph-tutorial-the-code-classifier%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F07%2Fjava-neuroph-tutorial-the-code-classifier%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/07/java-neuroph-tutorial-the-code-classifier/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Eclipse tips and tricks &#8211; Part 3</title>
		<link>http://www.certpal.com/blogs/2010/06/eclipse-tips-and-tricks-part-3/</link>
		<comments>http://www.certpal.com/blogs/2010/06/eclipse-tips-and-tricks-part-3/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 16:00:15 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[tricks]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=771</guid>
		<description><![CDATA[The following eclipse tips and tricks can be used to save the time you spend writing code in the IDE. Learn how to customize key bindings ; code suggestions ; workspaces ; revert back to your local history etc. ]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Feclipse-tips-and-tricks-part-3%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Feclipse-tips-and-tricks-part-3%2F" height="61" width="51" /></a></div><p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_logo.png"><img class="aligncenter size-full wp-image-775" style="border: 1px solid #cccccc;" title="eclipse_tips_tricks_3_logo" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_logo.png" alt="" width="128" height="128" /></a></p>
<p>Here are a few more tips / tricks with which you can save time when you use the eclipse IDE.</p>
<h2><span style="color: #333399;"><strong>Assign Key bindings:</strong></span></h2>
<p><span style="color: #333399;"><strong><br />
</strong></span></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_2.png"><img class="aligncenter size-full wp-image-781" title="eclipse_tips_tricks_3_2" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_2.png" alt="" width="655" height="411" /></a></p>
<p>Navigate to <span style="color: #333399;"><strong>Window -&gt; Preferences -&gt; General -&gt; Keys</strong></span></p>
<p>You will find that there are many key bindings that are not assigned to actions that you might do on a daily basis. For example, when I start up on a new project, it is highly likely that I will introduce a lot of Value Objects (or Transfer / Data object, whatever you like to call them). A slick feature is to generate the &#8216;Getters and Setters&#8217; for them using the &#8216;Source -&gt; Generate getter and setter&#8217; command from the Main menu.</p>
<p>You can either do that or you can assign a shortcut key to this action and get it done quickly. I use Alt+Shift+Q, +G (Yeah not the easiest combination. I know <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ). To restart eclipse I use Ctrl + F12. You might want to look at other bindings like</p>
<ul>
<li>Generate hashCode</li>
<li> Generate toString()</li>
<li> New package</li>
<li> New class</li>
</ul>
<p>And so on&#8230;</p>
<h2><span style="color: #333399;"><strong>Reduce number of code suggestions:</strong></span></h2>
<p><span style="color: #333399;"><strong><br />
</strong></span></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_1.png"><img class="aligncenter size-full wp-image-778" title="eclipse_tips_tricks_3_1" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_1.png" alt="" width="565" height="263" /></a></p>
<p>The shortcut I use the most in eclipse is perhaps ctrl+space. Code completion is a real time saver. It can however be annoying when you press ctrl+space more than once by mistake. This by default, brings about suggestions for SWT templates among other things. You can turn this off by navigating to <span style="color: #333399;"><strong>Window -&gt; Preferences -&gt; Java -&gt; Edtior -&gt; Code Assist.</strong></span></p>
<h2><span style="color: #333399;"><strong>Import preferences:</strong></span></h2>
<p><span style="color: #333399;"><strong><br />
</strong></span></p>
<p><strong><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_7.png"><img class="aligncenter size-full wp-image-789" title="eclipse_tips_tricks_3_7" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_7.png" alt="" width="465" height="209" /></a><br />
</strong></p>
<p>If you are like me, your hard disk probably has more than 100 eclipse Workspaces. Developers usually customize their workspaces and it can take a while to do this. When you switch to the new workspace, some of the customization is lost because they were workspace specific. You can get them back easily by exporting your preferences in the old workspace and importing them again in the new one. Use the <span style="color: #333399;"><strong>File -&gt; Export / Import</strong></span> option to do this. Preferences like code formatting, code templates, default compiler settings etc will be readily available.</p>
<h2><strong><span style="color: #333399;">Remember more workspaces: (Works on myeclipse)</span></strong></h2>
<h2><strong><span style="color: #333399;"><br />
</span></strong></h2>
<p><strong><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_6.png"><img class="aligncenter size-full wp-image-786" title="eclipse_tips_tricks_3_6" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_6.png" alt="" width="489" height="131" /></a><br />
</strong></p>
<p>Use this technique to allow eclipse to give you more drop down choices when you startup. By default eclipse remembers the last 5 workspaces used. You can increase / decrease this number by navigating to <span style="color: #333399;"><strong>Window -&gt; Preferences -&gt; General -&gt; Startup and Shutdown -&gt; Workspaces.</strong></span></p>
<h2><span style="color: #333399;"><strong>Associate eclipse with an external browser like firefox :</strong></span></h2>
<p><span style="color: #333399;"><strong><br />
</strong></span></p>
<p><strong><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_3.png"><img class="aligncenter size-full wp-image-782" title="eclipse_tips_tricks_3_3" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_3.png" alt="" width="697" height="491" /></a><br />
</strong></p>
<p>Eclipse uses the system default browser. In most cases this is IE (gulp). You can change that by defining an external browser by navigating to <span style="color: #333399;"><strong>Window -&gt; Preferences -&gt; General -&gt; Web Browser.</strong></span>. This is great when you combine it with a plugin like Firebug. You get to code and debug HTML / CSS / Javascript all at once.</p>
<h2><span style="color: #333399;"><strong>Work with local history:</strong></span></h2>
<p><span style="color: #333399;"><strong><br />
</strong></span></p>
<p>Screwed up your java file and then saved it ? Yikes. Local history comes to your rescue. Every edit and save that you make in a file is saved as a local history in eclipse. Make use of this to revert changes when necessary.</p>
<p>To use this feature, right click on the file of your choice and click <span style="color: #333399;"><strong>Compare With -&gt; Local hisory. </strong></span>That should open up the entries in the &#8216;History&#8217; view.<br />
<a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_4.png"><img class="aligncenter size-full wp-image-783" title="eclipse_tips_tricks_3_4" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_4.png" alt="" width="355" height="162" /></a></p>
<p>Clicking on any of the history entries will open a diff window telling you the difference between the current entry and the previous edits. Ah ! time is saved.</p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_5.png"><img class="aligncenter size-full wp-image-784" title="eclipse_tips_tricks_3_5" src="http://www.certpal.com/blogs/wp-content/uploads/eclipse_tips_tricks_3_5.png" alt="" width="747" height="156" /></a></p>
<p>This is a 3 part article. If you would like to browse through the other tips, you can find them here</p>
<p><a href="http://www.certpal.com/blogs/2009/08/eclipse-tips-and-tricks-part-1/" target="_blank">Eclipse tips and tricks</a> &#8211; Part 1</p>
<p><a href="http://www.certpal.com/blogs/2009/09/eclipse-tips-and-tricks-part-2/" target="_blank"> Eclipse tips and tricks </a> &#8211; Part 2</p>
<p><script type="text/javascript">// <![CDATA[
  var dzone_url = 'http://www.certpal.com/blogs/2010/06/eclipse-tips-and-tricks-part-3/';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
  var dzone_title = 'Eclipse tips and tricks';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
  var dzone_blurb = 'The following eclipse tips and tricks can be used to save the time you spend writing code in the IDE. Learn how to customize key bindings ; code suggestions ; workspaces ; revert back to your local history etc. ';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
  var dzone_style = '2';
// ]]&gt;</script><br />
<script src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Feclipse-tips-and-tricks-part-3%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Feclipse-tips-and-tricks-part-3%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/06/eclipse-tips-and-tricks-part-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>How to improve your programming skills</title>
		<link>http://www.certpal.com/blogs/2010/06/how-to-improve-your-programming-skills/</link>
		<comments>http://www.certpal.com/blogs/2010/06/how-to-improve-your-programming-skills/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 16:35:55 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=732</guid>
		<description><![CDATA[Everyone introduces bugs into their code, whether they like it or not. Here are a few ways through which you can reduce the number of bugs in your code. Or at least, try ;)]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fhow-to-improve-your-programming-skills%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fhow-to-improve-your-programming-skills%2F" height="61" width="51" /></a></div><p>Ever visit sites like <a href="http://www.topcoder.com/tc/" target="_blank">topcoder.com</a> and solve a problem or two ? No ? You should and do so regularly. It will help find tune your programming / design skills. This is because solving the problems requires going though the following thought process</p>
<ol>
<li>Understanding the problem.</li>
<li>Thinking up a solution that covers all use cases.</li>
<li>Executing your thought process through code.</li>
<li>Testing.</li>
</ol>
<p>Now as simple as that sounds, it is not so easy to get right. Especially when you are competing with thousands of fellow coders for time. And when time is a constrain you usually select the first solution that comes to your head, which might not necessarily be the best. So there is that risk of your code timing out even if it is following the right logic. I would love to delve into a problem right about now and throw in some examples and illustration, but you get the point.</p>
<p>When the thought process that we follow is not well defined and we lose focus, it often leads to buggy code. Don&#8217;t believe me ? Here are some bugs I caught in a code base on a recent project.</p>
<p><a href="http://www.certpal.com/blogs/2010/03/bugs-the-most-common-kind/" target="_blank">Bug 1</a></p>
<p><a href="http://www.certpal.com/blogs/2010/04/yet-another-bug/" target="_blank">Bug 2</a></p>
<p><a href="http://www.certpal.com/blogs/2010/06/more-bugs/" target="_blank">Bug 3</a></p>
<p>There were more bugs identified after development than what is listed here. But what I wanted to highlight was that the problem was introduced into the system due to lack of focus and clarity of thought. Well, more often than not anyway. Other times the bug sneaks into the system because the number of test cases to test a method were not sufficient. </p>
<p>Have a look at this google research <a href="http://googleresearch.blogspot.com/2006/06/extra-extra-read-all-about-it-nearly.html" target="_blank">blog post about broken binary search and merge sort algorithms</a> for example. They pretty much have the same bug as the <a href="http://www.certpal.com/blogs/2010/04/yet-another-bug/" target="_blank">date calculation bug</a> that I highlighted in a different post. We are all prone to creating bugs, but we can minimize the number of ones we introduce into the system.</p>
<p>So what have I learned from introducing bugs so far ?</p>
<ol>
<li>As long as you keep your skills sharp and practice solving problems, the number of bugs you introduce will reduce. I try to visit sites like <a href="http://www.topcoder.com/tc/" target="_blank">topcoder.com</a> or <a href="http://codingbat.com/" target="_blank">codingbat.com</a> whenever I find the time.</li>
<li>Learning from other&#8217;s mistakes and best practices can save you tons of time.</li>
<li>Try not to cram in your work within X hours. This tends to focus the effort on finishing the code on time instead of writing it neat and bug free.</li>
</ol>
<p>As always its easier said than done. But hey, its never too late eh ? As for finding the bugs in the first place&#8230;</p>
<ol>
<li>Use a tool like <a href="http://findbugs.sourceforge.net/" target="_self">FindBugs</a> after you are done coding. You will be surprised at how many problems turn up.</li>
<li>Try to maintain a code coverage of at least 80 %. Tools like <a href="http://emma.sourceforge.net/" target="_blank">Emma</a> can help you track this.</li>
</ol>
<p><script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/06/how-to-improve-your-programming-skills/';</script><br />
<script type="text/javascript">var dzone_title = 'How to improve your programming skills';</script><br />
<script type="text/javascript">var dzone_blurb = 'Everyone introduces bugs into their code, whether they like it or not. Here are a few ways through which you can reduce the number of bugs in your code. Or at least, try <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  ';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script> </p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fhow-to-improve-your-programming-skills%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fhow-to-improve-your-programming-skills%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/06/how-to-improve-your-programming-skills/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>More bugs</title>
		<link>http://www.certpal.com/blogs/2010/06/more-bugs/</link>
		<comments>http://www.certpal.com/blogs/2010/06/more-bugs/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 09:02:32 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[bug]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=742</guid>
		<description><![CDATA[Another bug that I stumbled across while testing some code. Squashed this one after some analysis.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fmore-bugs%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fmore-bugs%2F" height="61" width="51" /></a></div><p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/bug.png"><img class="aligncenter size-full wp-image-637" style="border: 1px dashed blue;" title="bug" src="http://www.certpal.com/blogs/wp-content/uploads/bug.png" alt="" width="213" height="176" /></a></p>
<p>I ran into another sweet little bug that I thought I would share with you. This one cropped up after it passed a few tests. See if you can spot the problem. Without further delay here it is</p>
<p><strong>Problem:</strong></p>
<p>A record needs to be inserted with a new identity number. This number is obtained as the next maximum ID value from a set of elements in a XML file. The following code is supposed to obtain the next ID from the XML. Lets skip the XML related code since that just adds clutter. </p>
<p><strong>Code:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">int</span> max <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> DataType data <span style="color: #339933;">:</span> someListFromTheXml <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>max <span style="color: #339933;">&lt;</span> data.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
         max <span style="color: #339933;">=</span> data.<span style="color: #006633;">getId</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
s_logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; Max id: &quot;</span> <span style="color: #339933;">+</span> max<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">return</span> max<span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>See anything wrong with it ? Its got a pretty big flaw. The logic works only for odd number of elements. When the number of elements is even, it fails. Here&#8217;s an illustration</p>
<p><strong>Test cases:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Test
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</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: #006633;">args</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> input1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> input2 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> input3 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> input4 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">2</span>,<span style="color: #cc66cc;">3</span>,<span style="color: #cc66cc;">4</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
        Test test <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Test<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        test.<span style="color: #006633;">go</span><span style="color: #009900;">&#40;</span>input1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        test.<span style="color: #006633;">go</span><span style="color: #009900;">&#40;</span>input2<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        test.<span style="color: #006633;">go</span><span style="color: #009900;">&#40;</span>input3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        test.<span style="color: #006633;">go</span><span style="color: #009900;">&#40;</span>input4<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        test.<span style="color: #006633;">go</span><span style="color: #009900;">&#40;</span>input5<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;">public</span> <span style="color: #000066; font-weight: bold;">void</span> go<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> input<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> max<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> id<span style="color: #339933;">:</span>input<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>max <span style="color: #339933;">&lt;</span> id<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                max <span style="color: #339933;">=</span> id<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</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><span style="color: #0000ff;">&quot; Max id: &quot;</span> <span style="color: #339933;">+</span> max<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Here&#8217;s the output:</p>
<p>Max id: 2<br />
Max id: 2<br />
Max id: 4<br />
Max id: 4<br />
Max id: 6</p>
<p>The logic incorrectly assigns the max to id+1. Instead it should have stored the current max and returned max+1 at the end of the loop. Sigh. </p>
<p>In hind sight a Xpath expression would have done nicely here. Something like max(/Parent/child/@value)+1. Still that is no excuse for the faulty logic <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/06/more-bugs/';</script><br />
<script type="text/javascript">var dzone_title = 'More bugs';</script><br />
<script type="text/javascript">var dzone_blurb = 'Another bug that I stumbled across while testing some code. Squashed this one after some analysis.';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script> </p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fmore-bugs%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F06%2Fmore-bugs%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/06/more-bugs/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How to configure log4j for a web app</title>
		<link>http://www.certpal.com/blogs/2010/05/how-to-configure-log4j-for-a-web-app/</link>
		<comments>http://www.certpal.com/blogs/2010/05/how-to-configure-log4j-for-a-web-app/#comments</comments>
		<pubDate>Thu, 06 May 2010 06:48:04 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[logs]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=698</guid>
		<description><![CDATA[A tutorial on configuring log4j for a java web application. This page shows you how to configure log4j for your application and the standards to follow while doing the same. Some examples are provided to aid the reader]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F05%2Fhow-to-configure-log4j-for-a-web-app%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F05%2Fhow-to-configure-log4j-for-a-web-app%2F" height="61" width="51" /></a></div><p><a href="http://www.certpal.com/blogs/wp-content/uploads/server_log.png"><img class="alignright size-full wp-image-703" title="server_log" src="http://www.certpal.com/blogs/wp-content/uploads/server_log.png" alt="server log" width="113" height="146" /></a>I often see environments where web applications use log4j for logging into files using various appenders. That is all well and good until I see that the logs are getting written into the application server&#8217;s logs. In JBOSS for example this is server.log. So why is this a bad idea ?</p>
<p><strong>Why not to write into server.log:</strong></p>
<ol>
<li>An application server&#8217;s log is supposed to be used by the app server and not by your application.</li>
<li>This log is supposed to contain app server level information like loading war files / exceptions that were handed over to the container etc.</li>
<li>Weeding through the logs of about 10 applications to find a particular debug / error line is going to be crazy.</li>
<li>A PROD logging configuration should never have a console appender. The reason your application logs are getting logged into the server&#8217;s logs could be that your log4j configuration defines a console appender. This could mean you are logging the same thing in 2 places (assuming there is another file appender defined for your app).</li>
</ol>
<p>Ideally each application should manage its own logging needs. Many developers seem to be unaware of a class named <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/DOMConfigurator.html" target="_blank">DomConfigurator</a> in the log4j API that can load a log4j XML and configure it for your application. Here are the steps I usually take to prepare an application for logging</p>
<ol>
<li> Write a custom class that implements ServletContextListener like the one shown below. The class looks for a context param named log4jFileName that is defined in web.xml. This locates the log4j XML configuration file. This will configure log4j before other classes use it.</li>
</ol>
<p><strong>Custom listener:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> StartupListener <span style="color: #000000; font-weight: bold;">implements</span> ServletContextListener
<span style="color: #009900;">&#123;</span>
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> contextDestroyed<span style="color: #009900;">&#40;</span>ServletContextEvent arg0<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Cleanup code goes here</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    @Override
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> contextInitialized<span style="color: #009900;">&#40;</span>ServletContextEvent sce<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        Logger logger <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        ServletContext servletContext <span style="color: #339933;">=</span> sce.<span style="color: #006633;">getServletContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> log4jFile <span style="color: #339933;">=</span> servletContext.<span style="color: #006633;">getInitParameter</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;log4jFileName&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        DOMConfigurator.<span style="color: #006633;">configure</span><span style="color: #009900;">&#40;</span>log4jFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        logger <span style="color: #339933;">=</span> LogManager.<span style="color: #006633;">getLogger</span><span style="color: #009900;">&#40;</span>StartupListener.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Loaded: &quot;</span> <span style="color: #339933;">+</span> log4jFile<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>2. In your web.xml define the listener and a context param like so</p>
<p><strong>Web.xml entries:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>log4jFileName<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
         /usr/local/app/log4j/config/log4jConfig.xml
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/param-value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/context-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        com.yourpackage.YourListener
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener-class<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/listener<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>3. Now configure your log4jConfig.xml appropriately to ensure that your application logs are logged under an appropriate path. Use a file appender like <a href="http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/RollingFileAppender.html" target="_blank">RollingFileAppender</a> to handle the retention policy for your applications.</p>
<p>Here is a sample log4j XML to help you</p>
<p><strong>Sample log4j XML: (Customize as necessary)</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;log4j:configuration</span> xmlns:log4j = <span style="color: #ff0000;">&quot;http://jakarta.apache.org/log4j/&quot;</span> debug = <span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appender</span> name = <span style="color: #ff0000;">&quot;FILE&quot;</span> class = <span style="color: #ff0000;">&quot;org.apache.log4j.RollingFileAppender&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> name = <span style="color: #ff0000;">&quot;File&quot;</span> value = <span style="color: #ff0000;">&quot;/usr/local/path/to/application.log&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> name = <span style="color: #ff0000;">&quot;MaxFileSize&quot;</span> value = <span style="color: #ff0000;">&quot;5MB&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> name = <span style="color: #ff0000;">&quot;MaxBackupIndex&quot;</span> value = <span style="color: #ff0000;">&quot;50&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;layout</span> class = <span style="color: #ff0000;">&quot;org.apache.log4j.PatternLayout&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> name = <span style="color: #ff0000;">&quot;ConversionPattern&quot;</span> value = <span style="color: #ff0000;">&quot;[%d{dd/MM/yy hh:mm:ss:sss z}] %5p %c{2}: %m%n&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/appender<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> name = <span style="color: #ff0000;">&quot;com.your.application.package&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;priority</span> value = <span style="color: #ff0000;">&quot;debug&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> name = <span style="color: #ff0000;">&quot;org.apache.catalina&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;priority</span> value = <span style="color: #ff0000;">&quot;error&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> name = <span style="color: #ff0000;">&quot;org.hibernate&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;priority</span> value = <span style="color: #ff0000;">&quot;error&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;priority</span> value = <span style="color: #ff0000;">&quot;info&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;appender-ref</span> ref = <span style="color: #ff0000;">&quot;FILE&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/root<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/log4j:configuration<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>That is pretty much it. This will ensure that your application&#8217;s logs are logged elsewhere from the server&#8217;s own logs. Makes managing log files a little easier. </p>
<p><script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/05/how-to-configure-log4j-for-a-web-app/';</script><br />
<script type="text/javascript">var dzone_title = 'How to configure log4j for a web app';</script><br />
<script type="text/javascript">var dzone_blurb = 'A tutorial on configuring log4j for a java web application. ';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script> </p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F05%2Fhow-to-configure-log4j-for-a-web-app%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F05%2Fhow-to-configure-log4j-for-a-web-app%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/05/how-to-configure-log4j-for-a-web-app/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Yet another bug</title>
		<link>http://www.certpal.com/blogs/2010/04/yet-another-bug/</link>
		<comments>http://www.certpal.com/blogs/2010/04/yet-another-bug/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 05:23:37 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[bug]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=686</guid>
		<description><![CDATA[Yet annother bug caused by a silly mistake. Bugs like these are easy to catch although they are not so evident when they are introduced into the code.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fyet-another-bug%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fyet-another-bug%2F" height="61" width="51" /></a></div><p><a href="http://www.certpal.com/blogs/wp-content/uploads/bug.png"><img class="aligncenter" style="border: 1px dashed blue;" title="bug" src="http://www.certpal.com/blogs/wp-content/uploads/bug.png" alt="" width="213" height="176" /></a></p>
<p>I came across another silly little bug today. Take a look at the code below (assume &#8216;days&#8217; is a parameter and that this snippet is part of a larger function)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">Date</span> now <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Date</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;">long</span> nowMillis <span style="color: #339933;">=</span> now.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Timestamp</span> nowTimestamp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Timestamp</span><span style="color: #009900;">&#40;</span>nowMillis<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000066; font-weight: bold;">long</span> future <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3600</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">24</span> <span style="color: #339933;">*</span> days <span style="color: #339933;">*</span> <span style="color: #cc66cc;">1000</span><span style="color: #339933;">;</span>
<span style="color: #003399;">Timestamp</span> expiryTimestamp <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Timestamp</span><span style="color: #009900;">&#40;</span>nowMillis <span style="color: #339933;">+</span> future<span style="color: #009900;">&#41;</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>nowTimestamp<span style="color: #009900;">&#41;</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>expiryTimestamp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Can you tell what is wrong with it ? What the code intends to do is to set an expiry timestamp to an element &#8211; X days from today. A caller called this code snippet with the value 5. Well there is nothing wrong so far. Here is the output</p>
<p>2010-<strong>04</strong>-<strong>27</strong> 10:37:10.497<br />
2010-<strong>05</strong>-<strong>02</strong> 10:37:10.497</p>
<p>So then came along an element that needed an expiry of around 40 days. The caller calls with the value 40. Guess what the output is</p>
<p>2010-04-<strong>27</strong> 10:38:43.372<br />
2010-04-<span style="color: #ff0000;"><strong>17</strong></span> 17:35:56.076</p>
<p>Umm&#8230; so the expiry date is *before* the current date. Super. So what is going wrong ? The value of future in this case is -838967296. Although future is a long type, the data type that is being calculated to assign a value to it, is int. An int cannot take anything more than Integer.MAX_VALUE (2147483647).</p>
<p>If future had been calculated correctly, its value would be 3456000000. Instead what is being presented is the wrapped around value obtained after adding the remainder to Integer.MIN_VALUE.</p>
<p>I guess that just goes to show that if it aint broke you may still need to fix it later. Of course that depends on what your definition of &#8216;broke&#8217; is <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/04/yet-another-bug/';</script><br />
<script type="text/javascript">var dzone_title = 'Yet another bug';</script><br />
<script type="text/javascript">var dzone_blurb = 'Yet annother bug caused by a silly mistake. Bugs like these are easy to catch although they are not so evident when they are introduced into the code.';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fyet-another-bug%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fyet-another-bug%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/04/yet-another-bug/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Eclipse and the conflicting shortcut problem</title>
		<link>http://www.certpal.com/blogs/2010/04/eclipse-conflicting-shortcuts-problem/</link>
		<comments>http://www.certpal.com/blogs/2010/04/eclipse-conflicting-shortcuts-problem/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 06:14:22 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[shortcut]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=677</guid>
		<description><![CDATA[Eclipse shortcuts can sometimes conflict with the ones defined by other applications. These series of steps should help you resolve these conflicts]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Feclipse-conflicting-shortcuts-problem%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Feclipse-conflicting-shortcuts-problem%2F" height="61" width="51" /></a></div><p><a href="http://www.certpal.com/blogs/wp-content/uploads/shortcut_failure.png"><img class="alignright size-full wp-image-682" title="shortcut_failure" src="http://www.certpal.com/blogs/wp-content/uploads/shortcut_failure.png" alt="" width="165" height="143" /></a>I moved all development activities to linux recently. Part of the migration process involved getting used to some new apps like <a href="http://kopete.kde.org/" target="_blank">Kopete</a> / Pidgin / KDE Snapshot etc. It was a breeze until I started debugging my code in eclipse.</p>
<p>I frequently use the eclipse keyboard shortcuts to cut down the time I spend coding / debugging. One of my favorite is Ctrl + Shift + i , which will open up the inspection box for a particular variable. This shortcut just did not work. For quite a few days I did not understand why. The other shortcuts like fix imports ( ctrl + shift + o ) seemed to be working fine. That&#8217;s when I stumbled across a <a href="http://docs.kde.org/stable/en/kdenetwork/kopete/configuring.html" target="_blank">kopete shortcut</a>.</p>
<p>The shortcut Ctrl + Shift + i was also used by kopete to read messages. According to the documentation this was a global short cut that was valid in any KDE application. I closed kopete just to confirm that it was contributing to the problem and voila, Ctrl + Shift + i started to work inside eclipse once again. So the next time a shortcut does not work in eclipse you might want to</p>
<ol>
<li>Look at the Wondow -&gt; Preferences -&gt; Keys and ensure that the key is bound.</li>
<li>If it is bound, check other applications and make sure this is not a global shortcut used elsewhere.</li>
<li>If it is a global shortcut, change the key binding in eclipse or the other application.</li>
<li>Relax</li>
</ol>
<p><script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/04/eclipse-conflicting-shortcuts-problem';</script><br />
<script type="text/javascript">var dzone_title = 'Eclipse and the conflicting shortcut problem';</script><br />
<script type="text/javascript">var dzone_blurb = 'Eclipse shortcuts can sometimes conflict with the ones defined by other applications. These series of steps should help you resolve these conflicts';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script> </p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Feclipse-conflicting-shortcuts-problem%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Feclipse-conflicting-shortcuts-problem%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/04/eclipse-conflicting-shortcuts-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java neural networks and Neuroph &#8211; A tutorial</title>
		<link>http://www.certpal.com/blogs/2010/04/java-neural-networks-and-neuroph-a-tutorial/</link>
		<comments>http://www.certpal.com/blogs/2010/04/java-neural-networks-and-neuroph-a-tutorial/#comments</comments>
		<pubDate>Sun, 18 Apr 2010 16:26:38 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[network]]></category>
		<category><![CDATA[neural]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=650</guid>
		<description><![CDATA[Getting started with java neural networks is easy with Neuroph. The visual GUI and the java interface provide a mechanism for beginners to play around with the API.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fjava-neural-networks-and-neuroph-a-tutorial%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fjava-neural-networks-and-neuroph-a-tutorial%2F" height="61" width="51" /></a></div><p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_logo.png"><img class="alignright size-full wp-image-666" title="neuroph_logo" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_logo.png" alt="" width="257" height="148" /></a>The java neural network <a href="http://neuroph.sourceforge.net/" target="_blank">Neuroph</a> was making news recently about its <a href="http://netbeans.dzone.com/neuroph-hadoop-nb" target="_blank">integration with Hadoop</a>. Neural networks can solve some interesting problems once they are trained. This article aims to provide the baby steps necessary to writing your first java program that loads a trained neural network.</p>
<p>Before you even begin to read anything that follows, a basic understanding of neural network terminology and the concept behind the same is necessary. The following articles are great starting points to understanding neural networks</p>
<p><a href="http://www.dzone.com/links/neuroph_smart_java_apps_with_neural_networks_part.html" target="_blank">Neuroph and neural networks &#8211; Part 1</a></p>
<p><a href="http://www.dzone.com/links/neuroph_smart_java_apps_with_neural_networks_part_2.html" target="_blank">Neuroph and neural networks &#8211; Part 2</a></p>
<p><a href="http://www.dzone.com/links/neuroph_smart_java_apps_with_neural_networks_part_3.html" target="_blank">Neuroph and neural networks &#8211; Part 3</a></p>
<p><a href="http://www.ibm.com/developerworks/library/l-neural/" target="_blank">Intro to neural networks </a></p>
<h2><strong>Cars and Signals:</strong></h2>
<p>We will  simulate the scenario where cars wait at a signal and move only when the lights are green. This simple example should help get you started. Our aim is to define a neural network with the easyNeurons swing application; train it; import it into java and use it in an application.</p>
<p>There are 3 states for this signal</p>
<p>1. Red &#8211; Stay where you are</p>
<p>2. Yellow &#8211; Start your engines</p>
<p>3. Green &#8211; Go</p>
<p>The neural network will take 3 inputs and its architecture will be based on the multi layer perceptron setting. A hidden layer with 4 nodes will decide the output. The output itself will be based on one node, whose value will determine if the cars can move or not. This is what our network looks like so far</p>
<p><strong>Create the network in neuroph: Network -&gt; Multi layer Perceptron</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_create.png"><img class="aligncenter size-full wp-image-652" title="neuroph_traffic_create" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_create.png" alt="" width="422" height="165" /></a></p>
<p><strong>Basic network with no training: View -&gt; Graph<br />
</strong></p>
<p style="text-align: center;">
<p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/traffic_graph_no_train.png"><img class="aligncenter size-full wp-image-651" style="border: 1px dashed blue;" title="traffic_graph_no_train" src="http://www.certpal.com/blogs/wp-content/uploads/traffic_graph_no_train.png" alt="" width="286" height="204" /></a></p>
<p>Now we need to train the network so that the output will be as expected when the signals change. The rules are pretty simple and are shown below.To train the network we create a training set</p>
<p><strong>Neuroph training set:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train.png"><img class="aligncenter size-full wp-image-653" title="neuroph_traffic_train" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train.png" alt="" width="301" height="204" /></a></p>
<p><strong>Train the network to respond to the inputs:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_2.png"><img class="aligncenter size-full wp-image-654" title="neuroph_traffic_train_2" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_2.png" alt="" width="513" height="519" /></a></p>
<p>After the training rules have been laid out, it is time to train this network. Simply press on the Train button and select the appropriate training set to use.</p>
<p><strong>Set the parameters by which the network should learn:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_3.png"><img class="aligncenter size-full wp-image-655" title="neuroph_traffic_train_3" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_3.png" alt="" width="323" height="243" /></a></p>
<p><strong>The trained network:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_4.png"><img class="aligncenter size-full wp-image-656" title="neuroph_traffic_train_4" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_4.png" alt="" width="543" height="463" /></a></p>
<p>Now that we have our network trained, lets try giving it an input. An input of 0 0 1 means the signal is green and the vehicles can go through. The output produced in this case is shown below. The output will vary based on the function used in the training set / error rate and other factors. But what is to be highlighted here is that the output is nearing 1 when the signal is green. Our network works as expected.</p>
<p><strong>Signal is green and output is 1 (well almost <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  ):</strong></p>
<p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_4.png"></a><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_5.png"><img class="aligncenter size-full wp-image-657" style="border: 1px dashed blue;" title="neuroph_traffic_train_5" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_5.png" alt="" width="318" height="220" /></a></p>
<p>We can confirm how this decision was taken by the network by highlighting the weights. Additionally by representing the size of each node with respect to the activation contributed for that node, we can visualize how the input message propagates</p>
<p><strong>Weight / Activation  highlighting:</strong></p>
<p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_6.png"><img class="aligncenter size-full wp-image-660" style="border: 1px dashed blue;" title="neuroph_traffic_train_6" src="http://www.certpal.com/blogs/wp-content/uploads/neuroph_traffic_train_6.png" alt="" width="309" height="222" /></a></p>
<p>So now that we have a neural network up and running, how do we actually use this inside java code ? Its pretty simple. Save the project as a .nnet file. Lets call this neural_traffic.nnet. To load the nnet file into your java project, simple use the classes provided by Neuroph like so</p>
<p><strong>Loading a neural network into java:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TestTrafficNeural
<span style="color: #009900;">&#123;</span>
    NeuralNetwork network <span style="color: #339933;">=</span> NeuralNetwork.<span style="color: #006633;">load</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;neural_traffic.nnet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</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: #000000; font-weight: bold;">new</span> TestTrafficNeural<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">go</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: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> go<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        calculate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        calculate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        calculate<span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">1</span><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: #000066; font-weight: bold;">void</span> calculate<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span>... <span style="color: #006633;">input</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        network.<span style="color: #006633;">setInput</span><span style="color: #009900;">&#40;</span>input<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        network.<span style="color: #006633;">calculate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">Vector</span> output <span style="color: #339933;">=</span> network.<span style="color: #006633;">getOutput</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">Double</span> answer <span style="color: #339933;">=</span> output.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</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>answer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The code produces the following output</p>
<p>-1.6360230873976706E-6<br />
-4.140786100885251E-6<br />
0.9684448970000741</p>
<p>You can also define and train the network on the fly with code. But you would not want to do this for cases where large sets of inputs and nodes are involved. For simple problems the time taken to train a network is usually a few seconds. For large images ( Assuming you are trying to recognize images with Neuroph ) it can take a couple of hours.</p>
<p>This example is pretty easy to do and is certainly not a practical use case for real world problems. However I hope it gets you excited about using neural networks in your programs. With Neuroph doing this is pretty simple.<br />
<script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/04/java-neural-networks-and-neuroph-a-tutorial/';</script><br />
<script type="text/javascript">var dzone_title = 'Java neural networks and Neuroph - A tutorial';</script><br />
<script type="text/javascript">var dzone_blurb = 'Getting started with java neural networks is easy with Neuroph. The visual GUI and the java interface provide a mechanism for beginners to play around with the API.';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script> </p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fjava-neural-networks-and-neuroph-a-tutorial%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fjava-neural-networks-and-neuroph-a-tutorial%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/04/java-neural-networks-and-neuroph-a-tutorial/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What is an AtomServer ?</title>
		<link>http://www.certpal.com/blogs/2010/04/what-is-an-atomserver/</link>
		<comments>http://www.certpal.com/blogs/2010/04/what-is-an-atomserver/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 15:25:43 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[atom]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=642</guid>
		<description><![CDATA[An introduction to the atom server and its possible use cases. The ATOM publishing protocol can be used to interact with feed entries. The ATOM server works with the ATOM Publishing protocol and stores the entries into its DB.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fwhat-is-an-atomserver%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fwhat-is-an-atomserver%2F" height="61" width="51" /></a></div><p>I had the opportunity to work with the ATOM protocol in detail recently. One of the products related to ATOM that I stumbled across is the <a href="http://atomserver.codehaus.org/" target="_blank">AtomServer.</a> If you dont already know it, ATOM is accompanied by a publishing protocol. Its called ATOMPub in short. Unlike RSS this protocol allows you to perform CRUD operations on the entries that you define under a feed.</p>
<p>What does that mean ? For example, you could have an entry in a feed which you wish to edit. You can edit / remove this entry using PUT / DELETE HTTP requests to an appropriate URL hosted by a server. So this protocol allows a user to interact with the feed (among other things. The ATOM XML format can be extended).</p>
<p>So what does the ATOMServer do and where does it fit in here ? The ATOMServer provides a RESTful interface and a RDBMS that stores the entries that the user interacts with. A user may wish to store 10 entries in a feed and then later retrieve and edit them as needed. To do this in an ATOM server the following operations would be invoked</p>
<ol>
<li> 10 PUT / POST requests to store the entries</li>
<li>A GET operation to retrieve the entry.</li>
<li>A few PUT requests to edit existing entries</li>
</ol>
<p>You can go through the <a href="http://atomserver.codehaus.org/docs/protocol_basics.html#insert-post" target="_blank">protocol basics</a> . The Google <a href="http://code.google.com/apis/gdata/" target="_blank">GData API</a> uses ATOMPub as the protocol to talk to various services such as Blogger / Google spreadsheet / Youtube etc etc. Whether they use an ATOMServer like product behind the scenes is debatable. The ATOMServer is by itself made up of pluggable components. You could easily replace the RDBMS store with a custom store of your own for example.</p>
<p>So where is an ATOMServer useful ? If you have existing services that need to be Atom enabled, the ATOMServer can provide the framework necessary to accomplish that. The ATOMServer can act as a layer that serves feed readers. The results for a feed can initially be fetched from an external source, such as an existing API or a file.</p>
<p>A search query that needs to refresh a feed every 30 minutes for example can be integrated with an ATOMServer. On the first call the search results would be fetched and stored into the ATOMServer DB. All subsequent feed reader calls to the ATOMServer for the next 30 minutes can be configured to get the cached data from the DB instead of the search query (A little coding into the ATOMServer framework would be required ). It is a simple use case and I am sure many more exist.</p>
<p>Another way to integrate ATOM into your APIs / services is to use <a href="http://abdera.apache.org/" target="_blank">Apache Abdera</a>. Abdera provides APIs that can generate ATOM XMLs. The ATOMServer is by itself built on top of Abdera. So if you need more flexibility you can go ahead and use Abdera directly.</p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fwhat-is-an-atomserver%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F04%2Fwhat-is-an-atomserver%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/04/what-is-an-atomserver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bugs &#8211; The most common kind</title>
		<link>http://www.certpal.com/blogs/2010/03/bugs-the-most-common-kind/</link>
		<comments>http://www.certpal.com/blogs/2010/03/bugs-the-most-common-kind/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 04:02:18 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[code]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=627</guid>
		<description><![CDATA[Bugs are introduced into code inevitably. Most bugs are introduced due to minor errors made in logic or errors introduced when code is copied and pasted into a location. This highlights the need for tools like FindBugs]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fbugs-the-most-common-kind%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fbugs-the-most-common-kind%2F" height="61" width="51" /></a></div><p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/bug.png"><img class="aligncenter size-full wp-image-637" style="border: 1px dashed #4665FF;" title="bug" src="http://www.certpal.com/blogs/wp-content/uploads/bug.png" alt="" width="213" height="176" /></a></p>
<p style="text-align: center;">
<p style="text-align: left;">I was testing an application today and came across a bug. A screen had some CRUD operations on a resource. The problem was, whatever I did, the system would perform the operation and tell me that the resource already existed. This left me scratching my head for quite a while. I add a resource and it says it already exists and then adds it. Delete and update also do the same.</p>
<p>So the debugging process started and I sat down with eclipse to get to the root of the problem. I verified that indeed the CRUD operations were reflecting in the persistence store. Then I came across these magical lines of code</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><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: #003399;">String</span> S_SOMETHING_EXISTS <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.already.exists&quot;</span><span style="color: #339933;">;</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: #003399;">String</span> S_SOMETHING_ADD_SUCCESS <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.already.exists&quot;</span><span style="color: #339933;">;</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: #003399;">String</span> S_SOMETHING_DELETE_FAIL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.already.exists&quot;</span><span style="color: #339933;">;</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: #003399;">String</span> S_SOMETHING_DELETE_SUCCESS <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.already.exists&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This left me smacking my head. It should have been</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><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: #003399;">String</span> S_SOMETHING_EXISTS <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.already.exists&quot;</span><span style="color: #339933;">;</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: #003399;">String</span> S_SOMETHING_ADD_SUCCESS <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.add.success&quot;</span><span style="color: #339933;">;</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: #003399;">String</span> S_SOMETHING_DELETE_FAIL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.delete.failed&quot;</span><span style="color: #339933;">;</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: #003399;">String</span> S_SOMETHING_DELETE_SUCCESS <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;something.delete.success&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The bug was introduced when I copied the first constant and pasted it three times. I forgot to change the keys <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_mrgreen.gif' alt=':mrgreen:' class='wp-smiley' /> . My point is, most of the bugs that I see introduced into the system are due to silly mistakes like the one above. This is where tools like FindBugs (which can be extended with your own rules) and CheckStyle and other bug finder / code review tools come in handy. A human code review is also a great tool. This little bug served as a reminder as to why we have such tools. To a developer this bug might seem small, but wait till an end user sees the message and says &#8216;What gives !&#8217;.</p>
<p><script type="text/javascript">// <![CDATA[
var dzone_url = 'http://www.certpal.com/blogs/2010/03/bugs-the-most-common-kind/';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
var dzone_title = 'Bugs - The most common kind';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
var dzone_blurb = 'Bugs are introduced into code inevitably. Most bugs are introduced due to minor errors made in logic or errors introduced when code is copied and pasted into a location. This highlights the need for tools like FindBugs';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
var dzone_style = '2';
// ]]&gt;</script><br />
<script src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fbugs-the-most-common-kind%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fbugs-the-most-common-kind%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/03/bugs-the-most-common-kind/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Application support for java developers in linux</title>
		<link>http://www.certpal.com/blogs/2010/03/application-support-for-java-developers-in-linux/</link>
		<comments>http://www.certpal.com/blogs/2010/03/application-support-for-java-developers-in-linux/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 04:28:06 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=618</guid>
		<description><![CDATA[Linux, for java developers, can support a wide range of tools / applications. Developers and users alike can be just as productive at what they did in windows. Here are a list of applications used in windows and their alternative / support in linux, just in case you are wondering if making the switch is smooth and easy.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fapplication-support-for-java-developers-in-linux%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fapplication-support-for-java-developers-in-linux%2F" height="61" width="51" /></a></div><p>One of the things I hear often from someone wanting to try linux and leave windows is that they are afraid that they will no longer be able perform some of the things they used to do. That is so wrong. Be it from the perspective of a developer or a casual user linux offers a wide range of apps to suit your needs. Here is a table of things I used to do in windows that I can still do in linux</p>
<table border="1" cellspacing="0" cellpadding="4" width="100%" bordercolor="#000000">
<col width="85*"></col>
<col width="85*"></col>
<col width="85*"></col>
<thead>
<tr valign="TOP">
<th width="33%">Application</th>
<th width="33%">Windows</th>
<th width="33%">Suse Linux &#8211; KDE desktop</th>
</tr>
</thead>
<tbody>
<tr valign="TOP">
<td width="33%"><strong>Chat</strong></td>
<td width="33%">Gtalk, Skype</td>
<td width="33%">Kopete / pidgin for gtalk</p>
<p>Skype is supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Development</strong></td>
<td width="33%">Eclipse / myeclipse / Netbeans</td>
<td width="33%">All of them have linux flavours</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Screenshot</strong></td>
<td width="33%">Gadwin printscreen</td>
<td width="33%">Ksnapshot</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Browsing</strong></td>
<td width="33%">Chrome / Firefox / Opera</td>
<td width="33%">They are all supported. Chrome support is getting better</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>SQL Client</strong></td>
<td width="33%">Squirrel SQL</td>
<td width="33%">Supported. Java runs anywhere <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Application server</strong></td>
<td width="33%">Tomcat / Glassfish</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Web server</strong></td>
<td width="33%">Apache</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Video player</strong></td>
<td width="33%">DivX , VLC</td>
<td width="33%">VLC is supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Package management</strong></td>
<td width="33%">None</td>
<td width="33%">Yast,yum, apt etc etc</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Firewall</strong></td>
<td width="33%">Inbuilt / Zone alarm</td>
<td width="33%">IP Tables. Much more flexible</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Database</strong></td>
<td width="33%">Postgres</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Desktop customization</strong></td>
<td width="33%">Not bad</td>
<td width="33%">Amazing. You can add widgets, multiple panels etc etc</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Multiple desktop support</strong></td>
<td width="33%">No</td>
<td width="33%">Yes</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Dual screen / Nvidia drivers</strong></td>
<td width="33%">Yes</td>
<td width="33%">Yes</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Remote desktop</strong></td>
<td width="33%">Windows / VNC</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Windows applications</strong></td>
<td width="33%">Yes (Duh)</td>
<td width="33%">Simulate with WINE</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Office</strong></td>
<td width="33%">Windows office</td>
<td width="33%">Open office. Not great but ok. You can use an online office suite if needed.</td>
</tr>
</tbody>
</table>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px;">
<p><!-- 		@page { margin: 0.79in } 		TD P { margin-bottom: 0in } 		TH P { margin-bottom: 0in } 		P { margin-bottom: 0.08in } --></p>
<table border="1" cellspacing="0" cellpadding="4" width="100%" bordercolor="#000000">
<col width="85*"></col>
<col width="85*"></col>
<col width="85*"></col>
<thead>
<tr valign="TOP">
<th width="33%">Application</th>
<th width="33%">Windows</th>
<th width="33%">Linux</th>
</tr>
</thead>
<tbody>
<tr valign="TOP">
<td width="33%"><strong>Chat</strong></td>
<td width="33%">Gtalk, Skype</td>
<td width="33%">Kopete / pidgin for gtalk</p>
<p>Skype is supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Development</strong></td>
<td width="33%">Eclipse / myeclipse / Netbeans</td>
<td width="33%">All of them have linux flavours</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Screenshot</strong></td>
<td width="33%">Gadwin printscreen</td>
<td width="33%">Ksnapshot</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Browsing</strong></td>
<td width="33%">Chrome / Firefox / Opera</td>
<td width="33%">They are all supported. Chrome support is getting better</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>SQL Client</strong></td>
<td width="33%">Squirrel SQL</td>
<td width="33%">Supported. Java runs anywhere <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Application server</strong></td>
<td width="33%">Tomcat / Glassfish</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Web server</strong></td>
<td width="33%">Apache</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Video player</strong></td>
<td width="33%">DivX , VLC</td>
<td width="33%">VLC is supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Package management</strong></td>
<td width="33%">None</td>
<td width="33%">Yast,yum, apt etc etc</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Firewall</strong></td>
<td width="33%">Inbuilt / Zone alarm</td>
<td width="33%">IP Tables. Much more flexible</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Database</strong></td>
<td width="33%">Postgres</td>
<td width="33%">Supported</td>
</tr>
<tr valign="TOP">
<td width="33%"><strong>Desktop customization</strong></td>
<td width="33%">Not bad</td>
<td width="33%">Amazing. You can add widgets, multiple panels etc etc</td>
</tr>
</tbody>
</table>
</div>
<p>The list above is just a sample of the applications I use. I am sure there are more use cases.</p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fapplication-support-for-java-developers-in-linux%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Fapplication-support-for-java-developers-in-linux%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/03/application-support-for-java-developers-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux for java development</title>
		<link>http://www.certpal.com/blogs/2010/03/linux-for-java-development/</link>
		<comments>http://www.certpal.com/blogs/2010/03/linux-for-java-development/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 02:43:07 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[suse]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=588</guid>
		<description><![CDATA[If you are considering to move your java development from Windows to Linux, here are a few pointers to take in mind. The move can be made easily and you can still do everything that you did in Windows. Linux is much from flexible and if you are willing to scale the learning curve, you have it made.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Flinux-for-java-development%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Flinux-for-java-development%2F" height="61" width="51" /></a></div><p style="text-align: center;"><a href="http://www.certpal.com/blogs/wp-content/uploads/win-to-linux.png"><img class="aligncenter size-full wp-image-589" style="border: 1px dashed #4281FF;" title="win-to-linux" src="http://www.certpal.com/blogs/wp-content/uploads/win-to-linux.png" alt="" width="531" height="264" /></a></p>
<p style="text-align: left;">
<p style="text-align: left;">
<p style="text-align: left;">I have been wanting to move to a linux based environment for java development for quite a while now. Many PROD servers I deploy to run on a linux distro. So testing configuration / code changes becomes easier when you have multiple DEV environments. I deploy to CentOS among other linux flavors. I have settled on the Open  Suse 11.2 desktop. Here are some things I liked</p>
<ol>
<li>Open Suse managed to detect my Nvidia driver with Yast. I guess they teamed up with Nvidia to host a repository for linux drivers. I didnt have to download kernel sources or devels to enable dual monitor support (Which is otherwise required). Nice !</li>
<li>PPP over internet setup was pretty easy. Kinternet and the Yast configuration settings together let me connect to the net with ease.</li>
<li>Community support seems good. The Suse forums are alive and kicking.</li>
<li>In general there was software by default on the desktop that turned out to be very useful. I didn&#8217;t have to download extra components unless it was specific to my hardware, like a specialized driver.  ksnapshot for example is a cool way to capture screenshots.</li>
</ol>
<p>I am yet to try out Ubuntu. For some reason it does not detect all my hardware so it fails to install <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' />  If you are still using windows to develop in java here are a few reasons you should switch</p>
<ol>
<li>Looks good on your resume. Learning to work with another OS / Desktop can broaden your perspective on getting things done.</li>
<li>Not as many viruses.</li>
<li>No IE <img src='http://www.certpal.com/blogs/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>If you are someone that loves the command line client, you will enjoy getting things done quickly with the shell console.</li>
<li>Firewall configuration is pretty flexible and can be bent into any shape you want provided you know what you are doing.</li>
<li>Automatic updates managed by a package manager</li>
<li>You can switch to multiple workspaces to manage your windows.</li>
<li>etc etc.</li>
</ol>
<p>That said I did find some minor annoyances.</p>
<ol>
<li>No IE. Whether I like it or not some users still use IE to access some of my apps. So my selenuim based RC test cases will not fire the IE window anymore. I have to use tools like BrowserShots or Adobe&#8217;s BrowserLab to get things done.</li>
<li>Some applications require me to run a .exe file as a plugin. This is very rare but can be overcome by simulating programs on Wine.</li>
<li>Learning new shortcuts can be a pain. So if you feel frustrated dont give up. Remember that you had to do the same with windows when you started out. So it will ease with time.</li>
</ol>
<p>I am able to do everything that I used to do with windows and there are free tools  that support just about any software function you can think of.  Not being able to find the tools / software you need is just a myth. Almost any function you can think of that you are currently using in windows, is supported under linux. Make the switch and enjoy the stability of linux. Use another distro besides Open Suse ? Feel free to leave a comment.</p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Flinux-for-java-development%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F03%2Flinux-for-java-development%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/03/linux-for-java-development/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Nautilus SVN moves to RabbitVCS</title>
		<link>http://www.certpal.com/blogs/2010/02/nautilus-svn-rabbitvcs/</link>
		<comments>http://www.certpal.com/blogs/2010/02/nautilus-svn-rabbitvcs/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 04:33:22 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=569</guid>
		<description><![CDATA[Nautilus SVN moves to the RabbitVCS project. Some developers have reported better load times with the new project. If you are using SVN to manage your projects on linux, give this software a try]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F02%2Fnautilus-svn-rabbitvcs%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F02%2Fnautilus-svn-rabbitvcs%2F" height="61" width="51" /></a></div><p><a href="http://www.certpal.com/blogs/wp-content/uploads/rabbitvcs-rabbit.png"><img class="alignright size-full wp-image-572" title="rabbitvcs-rabbit" src="http://www.certpal.com/blogs/wp-content/uploads/rabbitvcs-rabbit.png" alt="" width="64" height="94" /></a>Nautilus SVN, the SVN client for linux had moved to <a href="http://rabbitvcs.org/" target="_blank">RabbitVCS </a> a few months back. From what I have read so far, the new client, while plugging into the old Nautilus manager, performs much better and does not hang up when the number of files to manage is on the rise. </p>
<p>RabbitVCS differs from Nautilus by attempting to have a pluggable interface for many types of source control systems. So SVN is just the beginning. You can check out the <a href="http://wiki.rabbitvcs.org/wiki/about/screenshots " target="_blank">screenshots</a> and install it on your favorite linux distro.  Here are a few teasers</p>
<p><strong>RabbitVCS:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/rabbitvcs-1.png"><img class="aligncenter size-full wp-image-570" title="rabbitvcs-1" src="http://www.certpal.com/blogs/wp-content/uploads/rabbitvcs-1.png" alt="" width="412" height="552" /></a></p>
<p><strong>Commit with the Rabbit:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/rabbitvcs-2.png"><img class="aligncenter size-full wp-image-571" title="rabbitvcs-2" src="http://www.certpal.com/blogs/wp-content/uploads/rabbitvcs-2.png" alt="" width="655" height="653" /></a><br />
<script type="text/javascript">var dzone_url = 'http://www.certpal.com/blogs/2010/02/nautilus-svn-rabbitvcs/';</script><br />
<script type="text/javascript">var dzone_title = 'Nautilus SVN moves to RabbitVCS';</script><br />
<script type="text/javascript">var dzone_blurb = 'Nautilus SVN moves to the RabbitVCS project. Some developers have reported better load times with the new project. If you are using SVN to manage your projects on linux, give this software a try';</script><br />
<script type="text/javascript">var dzone_style = '2';</script><br />
<script language="javascript" src="http://widgets.dzone.com/links/widgets/zoneit.js"></script> </p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F02%2Fnautilus-svn-rabbitvcs%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F02%2Fnautilus-svn-rabbitvcs%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/02/nautilus-svn-rabbitvcs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sun certification java ee 6 updates</title>
		<link>http://www.certpal.com/blogs/2010/01/sun-certification-jee-6/</link>
		<comments>http://www.certpal.com/blogs/2010/01/sun-certification-jee-6/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 16:28:45 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[certification]]></category>
		<category><![CDATA[javaee]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=539</guid>
		<description><![CDATA[A brief look at the certifications that Sun has planned to bring forward after the release of JEE6. Prepare yourself with this certification roadmap if you are gearing towards updating your certification or earning new ones.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F01%2Fsun-certification-jee-6%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F01%2Fsun-certification-jee-6%2F" height="61" width="51" /></a></div><p>Sun has a wide range of certifications to offer. Ever since java EE6 was released, changes have been made to the certification hierarchy and content to reflect the new specifications. Sun is also offering a discount of 10% to those that register for training / certification updates by Jan 31st 2010. Here is a comparison of the certification hierarchies</p>
<p><strong>Old hierarchy:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/sun_cert_hierarchy_old.png"><img class="aligncenter size-full wp-image-541" title="sun_cert_hierarchy_old" src="http://www.certpal.com/blogs/wp-content/uploads/sun_cert_hierarchy_old.png" alt="" width="608" height="203" /></a></p>
<p><strong>New hierarchy:</strong></p>
<p><a href="http://www.certpal.com/blogs/wp-content/uploads/sun_cert_hierarchy_new.png"><img class="aligncenter size-full wp-image-542" title="sun_cert_hierarchy_new" src="http://www.certpal.com/blogs/wp-content/uploads/sun_cert_hierarchy_new.png" alt="" width="609" height="558" /></a></p>
<p>The new hierarchy provides paths that are more specialized than the ones before. For example you can be a JSF expert. Web service + security is another specialization. Combining these certifications together can also earn you the title of a &#8220;<strong>Master</strong>&#8220;.</p>
<p>Apart from these changes, the core java certification &#8211; SCJP &#8211; is supposed to undergo an overhaul after the release of JDK7. Candidates are expected to code their way into passing an exam instead of selecting multiple choice questions. The exam is supposed to be renamed as SCJP plus. It was delayed after an <a href="http://www.selikoff.net/2009/08/27/scjp-java-programmer-plus-certification-delayed/" target="_blank">earlier attempt to launch it was unsuccessful</a> due to the JDK7 project taking higher priority. Whether we will see &#8220;plus&#8221; versions of developing web pages / invoking web services etc etc is yet to be seen.</p>
<p>Sun is about to provide an update to all its existing certifications. If you are interested in registering for training/notifications, you can <a href="http://www.sun.com/training/upcoming_java_ee_6.html" target="_blank">do so here</a>. At the time of this writing, there are 3 days left to register / get notifications.</p>
<p><script type="text/javascript">// <![CDATA[
 var dzone_url = 'http://www.certpal.com/blogs/2010/01/sun-certification-jee-6/';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
 var dzone_title = 'Sun certification java ee 6 updates';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
 var dzone_blurb = 'A brief look at the certifications that Sun has planned to bring forward after the release of JEE6. Prepare yourself with this certification roadmap if you are gearing towards updating your certification or earning new ones.';
// ]]&gt;</script><br />
<script type="text/javascript">// <![CDATA[
 var dzone_style = '2';
// ]]&gt;</script><br />
<script src="http://widgets.dzone.com/links/widgets/zoneit.js"></script></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F01%2Fsun-certification-jee-6%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2010%2F01%2Fsun-certification-jee-6%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2010/01/sun-certification-jee-6/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Wave needs a decent client</title>
		<link>http://www.certpal.com/blogs/2009/11/wave-needs-a-decent-client/</link>
		<comments>http://www.certpal.com/blogs/2009/11/wave-needs-a-decent-client/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 14:23:05 +0000</pubDate>
		<dc:creator>CertPal</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[wave]]></category>

		<guid isPermaLink="false">http://www.certpal.com/blogs/?p=469</guid>
		<description><![CDATA[A wave client is the need of the hour for google wave. The wave server has been open sourced and pretty much any one can host their own wave. However good clients are hard to come by. The best one that is open sourced hardly has any of the features that the GWT client of google has.]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fwave-needs-a-decent-client%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fwave-needs-a-decent-client%2F" height="61" width="51" /></a></div><p>I successfully installed a wave (google) server on a windows box a few days earlier. It was a great feeling. Here are the components that made up the server</p>
<ul>
<li> Open fire XMPP server</li>
</ul>
<ul>
<li> Postgres database to be used by XFire.</li>
</ul>
<ul>
<li> Wave related server jar which runs the server</li>
</ul>
<ul>
<li> Wave command line client that runs the simplistic console client.</li>
</ul>
<p>I started the console client and typed in a few commands to go through the waves. New, open, view waves were some commands that the command line console allowed you to execute. This client was a simple RI provided by google. If you would like to install a server on your own, take a look at the <a href="http://code.google.com/p/wave-protocol/wiki/Installation" target="_blank">installation instructions</a>.</p>
<p><strong>Wave console client:</strong></p>
<p><img class="aligncenter size-medium wp-image-475" title="wave-console-client" src="http://www.certpal.com/blogs/wp-content/uploads/wave-console-client-300x179.PNG" alt="wave-console-client" width="300" height="179" /></p>
<p>I also had the option of federating this server with wavesandbox.com but I held back. I wanted to test out the features of my wave server first. So, I went about hunting for a client. The GWT client that google showcased in its IO Dev preview was impressive. So surely they have an open source implementation of a decent wave client that can be installed somewhere ? It seems not.</p>
<p>I was a little disappointed with this. The best UI I could find that would integrate with a wave server <a href="http://github.com/Thomas101/GUI-client-for-google-Wave" target="_blank">was here</a>. This was a java client with very minimal functionality. That said you have to thank the author for providing it. Its about the only decent looking client that can talk with a wave server.</p>
<p>There are other clients out there. One written in adobe AIR called <a href="http://www.adobe.com/cfusion/marketplace/index.cfm?event=marketplace.offering&amp;offeringid=16581&amp;marketplaceid=1 " target="_blank">Waver</a> can be used as a desktop client for waves. However it only integrates with google wave, not other waves. Another one called <a href="http://www.getwaveboard.com/" target="_blank">WaveBoard</a> also seems to target google wave and Macs. I don&#8217;t own a Mac so I could not check it out.</p>
<p>This seems like the need of the hour to me. A good wave client. Not a &#8220;google wave&#8221; client but a &#8220;wave client&#8221;. Adoption of the wave will be much better if we had a good client to go with it. How many times have you seen blog posts about google wave with comments that go like &#8216;Oh boy I wish I had a google wave invite right now&#8217;. These people need not wait for an invite. You can download and install a working wave server. If you had a cool looking client, people all around the world could be using wave right now without a google invite at all. Lack of a good wave client seems to be a bottle neck to wave usage. We need tools like Outlook / Thunderbird / &lt;Your favorite mail client goes here&gt; that help us access email, do the same for wave.</p>
<p>So how desperate are people to get google wave invites ? Invites are being auctioned off at ebay for anywhere between 1-15$ ! That is how desperate they are.(Search for &#8216;google wave&#8217; in ebay) Now if only we had a cool looking client, these people could be waving away in another server much like google&#8217;s wave. May be there is a client out there right now and I am yet to find it. If you know of one, do feel free to comment. If there is none, a few programmers will have to get together and make a good looking one with all the features that the GWT google client has.</p>
<p><strong>Wave invites at ebay:</strong></p>
<p style="text-align: center;"><img class="aligncenter size-full wp-image-471" style="border: 1px solid black;" title="google-eave-invite-ebay" src="http://www.certpal.com/blogs/wp-content/uploads/google-eave-invite-ebay.PNG" alt="google-eave-invite-ebay" width="447" height="190" /></p>
<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fwave-needs-a-decent-client%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.certpal.com%2Fblogs%2F2009%2F11%2Fwave-needs-a-decent-client%2F" height="61" width="51" /></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.certpal.com/blogs/2009/11/wave-needs-a-decent-client/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
