<?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>Christoph Kiehl &#187; Java</title>
	<atom:link href="http://www.christophkiehl.com/category/java/feed" rel="self" type="application/rss+xml" />
	<link>http://www.christophkiehl.com</link>
	<description>Software Development - Java - Open Source</description>
	<lastBuildDate>Mon, 25 Aug 2008 14:07:58 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Book Review: Wicket In Action</title>
		<link>http://www.christophkiehl.com/book-review-wicket-in-action</link>
		<comments>http://www.christophkiehl.com/book-review-wicket-in-action#comments</comments>
		<pubDate>Mon, 25 Aug 2008 13:31:46 +0000</pubDate>
		<dc:creator>Chris Kiehl</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.christophkiehl.com/?p=16</guid>
		<description><![CDATA[Alright here is the short summary: Martijn and Eelco have done an amazing job writing a comprehensive yet easy to read book, that covers pretty much every aspect of Wicket and is more than recommended for everyone who wants to get started with Wicket.
Starting with the introduction they give you a good idea what Wicket [...]]]></description>
			<content:encoded><![CDATA[<p>Alright here is the short summary: Martijn and Eelco have done an amazing job writing a comprehensive yet easy to read book, that covers pretty much every aspect of <a href="http://wicket.apache.org/">Wicket</a> and is more than recommended for everyone who wants to get started with Wicket.</p>
<p>Starting with the introduction they give you a good idea what Wicket is and how it came into life. It outlines a lot of the reasons why Model 2 web frameworks suck and how Wicket does a better job. This already got me hooked because it&#8217;s always nice to read about different approaches.</p>
<h3>Wicket Architecture</h3>
<p>After explaining the wicket architecture they introduce the first sample application which is &#8230; no, not another pet store &#8230; a cheese store <img src='http://www.christophkiehl.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  But as you continue reading you will find that their writing is not cheesy at all. They&#8217;ve got a fresh style of writing which is not too boring but still delivers all the technical details you need, to thoroughly understand what&#8217;s going on.</p>
<p>The first two chapters of part 2 of the book go into detail about Wicket&#8217;s core elements: Models and Components. Understanding those and how they interact is the cornerstone of understanding Wicket.<br />
But to really fill your models and components with life, you will need to interact with your user and fill your application with data. Explaining how to process user input using forms including validation and what different layout concepts Wicket has to offer is covered by the next two chapters.</p>
<h3>Advanced Topics</h3>
<p>So what&#8217;s next? I already gained the knowledge to write my basic Wicket application, but there are still some advanced topics to cover:</p>
<ul>
<li>Developing reusable components</li>
<li>Images, CSS and scripts: working with resources</li>
<li>Rich components and AJAX</li>
</ul>
<p>If you ever build a bigger web application you&#8217;ll realize quickly that there are some topics left to explain. Does Wicket provide means of authentication and authorization? How does i18n work? Oh, and I want my application to integrate with Spring and Hibernate! And how do I test my wicked Wicket application?<br />
Fortunately all those questions and more are answered in the last part of the book called &#8220;Preparing for the real world&#8221;.</p>
<h3>Awesome Book</h3>
<p>Martijn and Eelco do a great job getting you up to speed with Wicket. But it&#8217;s not only about getting through those sample applications. What I love about the book is that it actually provides hands on instructions for real world applications which is often missing from such books. It&#8217;s probably due to the fact that they are both members of the core Wicket team and use Wicket on a daily basis. They are not another example of those authors that just decide that they are going to write a book about a topic, and then do the tutorials and hang around on the mailing lists to gather just enough information to fill a book.</p>
<p>To summarize: Well done! I wish this book was available about a year ago, when one of my colleagues tried to build his first Wicket application!</p>
<p>If you are thinking of buying <a href="http://www.manning.com/dashorst/">the book</a>, you should buy it now as they offer a 35% discount until the end of August.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophkiehl.com/book-review-wicket-in-action/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Performance Tuning: Object Creation Overhead</title>
		<link>http://www.christophkiehl.com/performance-tuning-object-creation-overhead</link>
		<comments>http://www.christophkiehl.com/performance-tuning-object-creation-overhead#comments</comments>
		<pubDate>Sat, 01 Dec 2007 17:53:41 +0000</pubDate>
		<dc:creator>christoph</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.christophkiehl.com/performance-tuning-object-creation-overhead</guid>
		<description><![CDATA[While working on a Jackrabbit issue I came across a method that is called about a million times for certain requests. In this method an ArrayList instance and a few Integer instances were created on each call to eventually build up a list of ints. I thought I might give it a try and use [...]]]></description>
			<content:encoded><![CDATA[<p>While working on a <a href="http://jackrabbit.apache.org/" target="_blank">Jackrabbit</a> <a href="https://issues.apache.org/jira/browse/JCR-1251" target="_blank">issue</a> I came across a method that is called about a million times for certain requests. In this method an ArrayList instance and a few Integer instances were created on each call to eventually build up a list of ints. I thought I might give it a try and use an int array instead &#8211; lo and behold! That gave me an overall performance gain of about <b>40%</b>.</p>
<p>I wrote this little test code to show the difference:</p>
<div class="codecolorer-container java"><div class="codecolorer" style="font-family: monospace;"><span class="co2">import java.util.ArrayList;</span><br />
<span class="co2">import java.util.List;</span><br />
<br />
<br />
<span class="kw2">public</span> <span class="kw2">class</span> ArrayPerformance <span class="br0">&#123;</span><br />
<br />
&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw4">int</span> LOOP_COUNT = <span class="nu0">10000000</span>;<br />
&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">static</span> <span class="kw2">final</span> <span class="kw4">int</span> ARRAY_SIZE = <span class="nu0">10</span>;<br />
<br />
&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">static</span> <span class="kw4">void</span> buildArrayList<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">long</span> start = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">currentTimeMillis</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i = <span class="nu0">0</span>; i &lt; LOOP_COUNT; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AList+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">List</span></a> values = <span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AArrayList+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">ArrayList</span></a><span class="br0">&#40;</span>ARRAY_SIZE<span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> j = <span class="nu0">0</span>; j &lt; ARRAY_SIZE; j++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; values.<span class="me1">add</span><span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInteger+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">Integer</span></a>.<span class="me1">valueOf</span><span class="br0">&#40;</span>j<span class="br0">&#41;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">long</span> end = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">currentTimeMillis</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printTime<span class="br0">&#40;</span>start, end, <span class="st0">&quot;ArrayList&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">static</span> <span class="kw4">void</span> buildArray<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">long</span> start = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">currentTimeMillis</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i = <span class="nu0">0</span>; i &lt; LOOP_COUNT; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">int</span><span class="br0">&#91;</span><span class="br0">&#93;</span> values = <span class="kw2">new</span> <span class="kw4">int</span><span class="br0">&#91;</span>ARRAY_SIZE<span class="br0">&#93;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> j = <span class="nu0">0</span>; j &lt; ARRAY_SIZE; j++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; values<span class="br0">&#91;</span>j<span class="br0">&#93;</span> = j;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw4">long</span> end = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">currentTimeMillis</span><span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; printTime<span class="br0">&#40;</span>start, end, <span class="st0">&quot;array&quot;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
<br />
&nbsp; &nbsp; <span class="kw2">private</span> <span class="kw2">static</span> <span class="kw4">void</span> printTime<span class="br0">&#40;</span><span class="kw4">long</span> start, <span class="kw4">long</span> end, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a> label<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">System</span></a>.<span class="me1">out</span>.<span class="me1">printf</span><span class="br0">&#40;</span><span class="st0">&quot;%-10s: %5dms<span class="es0">\n</span>&quot;</span>, <span class="kw2">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">Object</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span><span class="br0">&#123;</span>label, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ALong+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">Long</span></a>.<span class="me1">valueOf</span><span class="br0">&#40;</span>end-start<span class="br0">&#41;</span><span class="br0">&#125;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span class="kw2">public</span> <span class="kw2">static</span> <span class="kw4">void</span> main<span class="br0">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;bntI=I%27m%20Feeling%20Lucky"><span class="kw3">String</span></a><span class="br0">&#91;</span><span class="br0">&#93;</span> args<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span><span class="kw4">int</span> i = <span class="nu0">0</span>; i &lt; <span class="nu0">5</span>; i++<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buildArray<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; buildArrayList<span class="br0">&#40;</span><span class="br0">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <br />
<span class="br0">&#125;</span></div></div>
<p>The resulting output was this:</p>
<pre>
<div class="codecolorer-container dos"><div class="codecolorer" style="font-family: monospace;">array&nbsp; &nbsp; &nbsp;:&nbsp; &nbsp;<span class="re0">475ms</span><br />
ArrayList :&nbsp; <span class="re0">1200ms</span><br />
array&nbsp; &nbsp; &nbsp;:&nbsp; &nbsp;<span class="re0">353ms</span><br />
ArrayList :&nbsp; <span class="re0">1158ms</span><br />
array&nbsp; &nbsp; &nbsp;:&nbsp; &nbsp;<span class="re0">337ms</span><br />
ArrayList :&nbsp; &nbsp;<span class="re0">921ms</span><br />
array&nbsp; &nbsp; &nbsp;:&nbsp; &nbsp;<span class="re0">341ms</span><br />
ArrayList :&nbsp; &nbsp;<span class="re0">921ms</span><br />
array&nbsp; &nbsp; &nbsp;:&nbsp; &nbsp;<span class="re0">341ms</span><br />
ArrayList :&nbsp; &nbsp;<span class="re0">918ms</span></div></div>
</pre>
<p>Which shows that after some warming up the variant using an ArrayList with Integers to build up a list of ints is roughly about <b>3 times slower</b> than using a plain int array. </p>
<h3>What do I learn from this?</h3>
<p>If you know about code sections in your code base which are called millions of times make sure you try to find a solution without creating short living object instances, because even if the current JVM is quite fast creating and collection object instances, it still eats some CPU.<br />
This might lead to solutions that are not object oriented anymore, but this is a small drawback if it gives a performance critical part of your application a speedup.</p>
<p>Another thing is that using natives like ints or longs is always preferable over Integer or Long objects for performance critical code. <a href="http://lucene.apache.org/" target="_blank">Lucene</a> for example uses natives a lot to get the best performing code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophkiehl.com/performance-tuning-object-creation-overhead/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Suns Troubleshooting Guide for Java</title>
		<link>http://www.christophkiehl.com/suns-troubleshooting-guide-for-java</link>
		<comments>http://www.christophkiehl.com/suns-troubleshooting-guide-for-java#comments</comments>
		<pubDate>Mon, 17 Sep 2007 10:31:22 +0000</pubDate>
		<dc:creator>christoph</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.christophkiehl.com/?p=13</guid>
		<description><![CDATA[Suns Troubleshooting Guide for Java provides a nice overview of available tools to analyze and monitor Java processes. I would guess that a lot of Java developers doesn&#8217;t know them.
I recently had to identify a performance problem on one of our production servers. The application appeared to hang every few seconds and then continue normal [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://java.sun.com/javase/6/webnotes/trouble/TSG-VM/TSG-VM.pdf" target="_blank">Suns Troubleshooting Guide for Java</a> provides a nice overview of available tools to analyze and monitor Java processes. I would guess that a lot of Java developers doesn&#8217;t know them.</p>
<p>I recently had to identify a performance problem on one of our production servers. The application appeared to hang every few seconds and then continue normal operation. Using <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstat.html" target="_blank">jstat</a> I quickly discovered that there were a lot of objects created just to be garbage collected right after. This was the output of jstat:</p>
<pre>
<div class="codecolorer-container java"><div class="codecolorer" style="font-family: monospace;">S0&nbsp; &nbsp; &nbsp;S1&nbsp; &nbsp; &nbsp;E&nbsp; &nbsp; &nbsp; O&nbsp; &nbsp; &nbsp; P&nbsp; &nbsp; &nbsp;YGC&nbsp; &nbsp; &nbsp;YGCT&nbsp; &nbsp; FGC&nbsp; &nbsp; FGCT&nbsp; &nbsp; &nbsp;GCT&nbsp; &nbsp; LGCC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GCC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">75</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12922</span>,<span class="nu0">944</span> <span class="nu0">13649</span>,<span class="nu0">106</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">44</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12922</span>,<span class="nu0">944</span> <span class="nu0">13649</span>,<span class="nu0">106</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">21</span>,<span class="nu0">93</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">47</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">32</span>,<span class="nu0">41</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">42</span>,<span class="nu0">44</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
S0&nbsp; &nbsp; &nbsp;S1&nbsp; &nbsp; &nbsp;E&nbsp; &nbsp; &nbsp; O&nbsp; &nbsp; &nbsp; P&nbsp; &nbsp; &nbsp;YGC&nbsp; &nbsp; &nbsp;YGCT&nbsp; &nbsp; FGC&nbsp; &nbsp; FGCT&nbsp; &nbsp; &nbsp;GCT&nbsp; &nbsp; LGCC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GCC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">56</span>,<span class="nu0">79</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">68</span>,<span class="nu0">61</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">78</span>,<span class="nu0">02</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">88</span>,<span class="nu0">74</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1192</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
S0&nbsp; &nbsp; &nbsp;S1&nbsp; &nbsp; &nbsp;E&nbsp; &nbsp; &nbsp; O&nbsp; &nbsp; &nbsp; P&nbsp; &nbsp; &nbsp;YGC&nbsp; &nbsp; &nbsp;YGCT&nbsp; &nbsp; FGC&nbsp; &nbsp; FGCT&nbsp; &nbsp; &nbsp;GCT&nbsp; &nbsp; LGCC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GCC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
S0&nbsp; &nbsp; &nbsp;S1&nbsp; &nbsp; &nbsp;E&nbsp; &nbsp; &nbsp; O&nbsp; &nbsp; &nbsp; P&nbsp; &nbsp; &nbsp;YGC&nbsp; &nbsp; &nbsp;YGCT&nbsp; &nbsp; FGC&nbsp; &nbsp; FGCT&nbsp; &nbsp; &nbsp;GCT&nbsp; &nbsp; LGCC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GCC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
S0&nbsp; &nbsp; &nbsp;S1&nbsp; &nbsp; &nbsp;E&nbsp; &nbsp; &nbsp; O&nbsp; &nbsp; &nbsp; P&nbsp; &nbsp; &nbsp;YGC&nbsp; &nbsp; &nbsp;YGCT&nbsp; &nbsp; FGC&nbsp; &nbsp; FGCT&nbsp; &nbsp; &nbsp;GCT&nbsp; &nbsp; LGCC&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;GCC<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">48</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12934</span>,<span class="nu0">808</span> <span class="nu0">13660</span>,<span class="nu0">970</span> Allocation Failure&nbsp; &nbsp;unknown GCCause<br />
<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; &nbsp;<span class="nu0">0</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">24</span>,<span class="nu0">36</span> <span class="nu0">100</span>,<span class="nu0">00</span>&nbsp; <span class="nu0">89</span>,<span class="nu0">51</span>&nbsp; <span class="nu0">10546</span>&nbsp; <span class="nu0">726</span>,<span class="nu0">162</span>&nbsp; <span class="nu0">1193</span> <span class="nu0">12946</span>,<span class="nu0">347</span> <span class="nu0">13672</span>,<span class="nu0">509</span> unknown GCCause&nbsp; &nbsp; &nbsp; No GC</div></div>
</pre>
<p>The &#8220;E&#8221; column denotes percent of Eden space used. In the time where this value is 100% the application doesn&#8217;t respond until the garbage collection took place.</p>
<p>Using <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jstack.html" target="_blank">jstack</a> I was able to find out what the server was doing while inflating the heap.</p>
<p>All this was done on a server running in production without using any additional profilers!</p>
<p>Another nice feature is the -XX:+HeapDumpOnOutOfMemoryError option mentioned in section 3.3.3.4 of the guide. I always set this option for production servers. This way you always have a memory dump available to analyze, even if the support team only restarted the application without taking a heap dump.</p>
<p>Or take <a href="http://java.sun.com/j2se/1.5.0/docs/tooldocs/share/jmap.html" target="_blank">jmap</a> for example. You can not only get some heap statistics but also generate a heap dump while the application is running.</p>
<p>So make sure you know about the tools available as they might become useful if your application ever gets into trouble <img src='http://www.christophkiehl.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophkiehl.com/suns-troubleshooting-guide-for-java/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Automatically create releases and maintenance branches with Maven</title>
		<link>http://www.christophkiehl.com/automatically-create-releases-and-maintenance-branches-with-maven</link>
		<comments>http://www.christophkiehl.com/automatically-create-releases-and-maintenance-branches-with-maven#comments</comments>
		<pubDate>Mon, 16 Jul 2007 22:43:05 +0000</pubDate>
		<dc:creator>christoph</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.christophkiehl.com/?p=12</guid>
		<description><![CDATA[First of all you need version at least 2.0-beta-6 of the Maven Release Plugin if you want the branching feature. I just deleted the &#60;home&#62;/.m2/repository/org/apache/maven/plugins/maven-release-plugin folder to get Maven to download the latest version. If you never used the release plugin before it will download the latest version anyway.
Now let&#8217;s say you&#8217;ve got version 1.0.0-SNAPSHOT [...]]]></description>
			<content:encoded><![CDATA[<p>First of all you need version at least 2.0-beta-6 of the <a href="http://maven.apache.org/plugins/maven-release-plugin/">Maven Release Plugin</a> if you want the branching feature. I just deleted the <em>&lt;home&gt;/.m2/repository/org/apache/maven/plugins/maven-release-plugin</em> folder to get Maven to download the latest version. If you never used the release plugin before it will download the latest version anyway.</p>
<p>Now let&#8217;s say you&#8217;ve got version 1.0.0-SNAPSHOT of your artifact and you want to cut a release: the normal procedure would be to run</p>
<div class="codecolorer-container text" style="height:35px;">mvn release:prepare release:perform</div>
<p>To get this running you need two prerequisites in you pom.xml:</p>
<ol>
<li>a scm section</li>
<li>a distributionManagement section</li>
</ol>
<p>Those might look like this:</p>
<div class="codecolorer-container xml"><div class="codecolorer" style="font-family: monospace;"><span class="sc3"><span class="re1">&lt;scm<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;connection<span class="re2">&gt;</span></span></span>scm:svn:http://<span class="sc3"><span class="re1">&lt;yourhost<span class="re2">&gt;</span></span></span>/release-test/trunk/<span class="sc3"><span class="re1">&lt;/connection<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;developerConnection<span class="re2">&gt;</span></span></span>scm:svn:http://<span class="sc3"><span class="re1">&lt;yourhost<span class="re2">&gt;</span></span></span>/release-test/trunk/<span class="sc3"><span class="re1">&lt;/developerConnection<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/scm<span class="re2">&gt;</span></span></span><br />
<br />
<span class="sc3"><span class="re1">&lt;distributionManagement<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;repository<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;id<span class="re2">&gt;</span></span></span>repo<span class="sc3"><span class="re1">&lt;/id<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;name<span class="re2">&gt;</span></span></span>Local Repo<span class="sc3"><span class="re1">&lt;/name<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;url<span class="re2">&gt;</span></span></span>file:///c:/tmp/repo<span class="sc3"><span class="re1">&lt;/url<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/repository<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/distributionManagement<span class="re2">&gt;</span></span></span></div></div>
<p>From now on I assume that your project name is <em>release-test</em>. You also need to make sure that there is a folder <em>http://&lt;yourhost&gt;/release-test/tags</em> in your repo. Maven needs this folder to tag the released version unless you told Maven otherwise.</p>
<p>Assure that everything is checked in and you&#8217;ve got no changes in your checked out copy. If you now call</p>
<div class="codecolorer-container text" style="height:35px;">mvn release:prepare release:perform</div>
<p>and accept 1.0.1-SNAPSHOT as the next development version Maven will nicely build your application, tag the sources in svn and modify your pom.xml to reflect the next development version. This is already quite cool and saves a lot of time. But &#8230;</p>
<p>&#8230; I like to create maintenance branches after such a release. So I would choose 1.1.0-SNAPSHOT as the next development version and create a branch containing a 1.0.1-SNAPSHOT version derived from the 1.0.0 Release. Creating branches and modifying pom.xmls is quite tedious (unless you wrote yourself a script to do the stupid work). This is where the release plugins new branch feature comes into play.</p>
<p>Before I create my 1.0.0 release I create a 1.0.x branch with Maven. Just make sure you&#8217;ve got a <em>http://&lt;yourhost&gt;/release-test/branches</em> folder in your repository. Now call</p>
<div class="codecolorer-container text" style="height:35px;">mvn release:branch -DbranchName=1.0.x</div>
<p>Maven will ask you for the new working copy version. Enter 1.1.0-SNAPSHOT as this will be our new bleeding edge development version. Maven now creates a branch at <em>http://&lt;yourhost&gt;/release-test/branches/1.0.x</em> which contains a pom.xml with version 1.0.0-SNAPSHOT and modifies the version in your trunks pom.xml to be 1.1.0-SNAPSHOT.
<p/>
<p>To finally cut your 1.0.0 release you have to checked out your branch <em>http://&lt;yourhost&gt;/release-test/branches/1.0.x</em> and do the usual</p>
<div class="codecolorer-container text" style="height:35px;">mvn release:prepare release:perform</div>
<p>which will suggest the correct version numbers. Subsequent maintenance release are created of this branch in the same fashion.</p>
<p>This got a bit longer than I thought <img src='http://www.christophkiehl.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  If you&#8217;ve got any questions &#8211; ask. I&#8217;ll be more than happy to go into further detail if needed</p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophkiehl.com/automatically-create-releases-and-maintenance-branches-with-maven/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Easy way to display your apps version number using Maven</title>
		<link>http://www.christophkiehl.com/easy-way-to-display-your-apps-version-using-maven-and-manifest</link>
		<comments>http://www.christophkiehl.com/easy-way-to-display-your-apps-version-using-maven-and-manifest#comments</comments>
		<pubDate>Wed, 30 May 2007 21:47:17 +0000</pubDate>
		<dc:creator>christoph</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.christophkiehl.com/?p=4</guid>
		<description><![CDATA[Recently I wanted to print our apps version number to the log file. Since I&#8217;m using Maven and the Maven Release Plugin to create releases of our app I was looking for an easy way to incorporate the version in the pom.xml into the release and display it.
Fortunately Maven already provides a hook to have [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I wanted to print our apps version number to the log file. Since I&#8217;m using <a href="http://maven.apache.org/" target="_blank">Maven</a> and the <a href="http://maven.apache.org/plugins/maven-release-plugin/" target="_blank">Maven Release Plugin</a> to create releases of our app I was looking for an easy way to incorporate the version in the pom.xml into the release and display it.</p>
<p>Fortunately Maven already provides a hook to have the version number written to a jars MANIFEST.MF. I simply added the following snippet to my pom.xml:</p>
<div class="codecolorer-container xml"><div class="codecolorer" style="font-family: monospace;"><span class="sc3"><span class="re1">&lt;build<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;plugins<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;plugin<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;groupId<span class="re2">&gt;</span></span></span>org.apache.maven.plugins<span class="sc3"><span class="re1">&lt;/groupId<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;artifactId<span class="re2">&gt;</span></span></span>maven-jar-plugin<span class="sc3"><span class="re1">&lt;/artifactId<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;configuration<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;archive<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;manifest<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;mainClass<span class="re2">&gt;</span></span></span>test.App<span class="sc3"><span class="re1">&lt;/mainClass<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;addDefaultImplementationEntries<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; true<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/addDefaultImplementationEntries<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/manifest<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/archive<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/configuration<span class="re2">&gt;</span></span></span><br />
&nbsp; &nbsp; <span class="sc3"><span class="re1">&lt;/plugin<span class="re2">&gt;</span></span></span><br />
&nbsp; <span class="sc3"><span class="re1">&lt;/plugins<span class="re2">&gt;</span></span></span><br />
<span class="sc3"><span class="re1">&lt;/build<span class="re2">&gt;</span></span></span></div></div>
<p>The important part is <em>addDefaultImplementationEntries</em>. This instructs Maven to add the following headers to the MANIFEST.MF of your jar:</p>
<div class="codecolorer-container text">Implementation-Title: display-version
Implementation-Version: 1.0-SNAPSHOT
Implementation-Vendor-Id: test</div>
<p>Now you can use this line of code to access the version number:</p>
<div class="codecolorer-container java" style="height:35px;"><div class="codecolorer" style="font-family: monospace;">App.<span class="kw2">class</span>.<span class="me1">getPackage</span><span class="br0">&#40;</span><span class="br0">&#41;</span>.<span class="me1">getImplementationVersion</span><span class="br0">&#40;</span><span class="br0">&#41;</span></div></div>
<p>where &#8220;App&#8221; is just any class in your jar.</p>
<p>In defiance of all those Maven haters out there thing are sometimes just that easy with Maven <img src='http://www.christophkiehl.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.christophkiehl.com/easy-way-to-display-your-apps-version-using-maven-and-manifest/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
