<?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>PearlChain Tech Blog</title>
	<atom:link href="http://javablog.pearlchain.net/wordpress/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://javablog.pearlchain.net/wordpress</link>
	<description>Sharing our experiences with the world</description>
	<lastBuildDate>Thu, 29 Jul 2010 14:30:30 +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>oracle jvm 1.6u21</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=435</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=435#comments</comments>
		<pubDate>Thu, 29 Jul 2010 13:40:48 +0000</pubDate>
		<dc:creator>Boris</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[java eclipse]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=435</guid>
		<description><![CDATA[As remarked on several places update 21 of 1.6 of the sun oracle jvm doesn&#8217;t work well when using lot of perm gem space.
This was caused because oracle changed the vendors name of the jvm to oracle. Because of this eclipse launcher didn&#8217;t see it was the sun oracle jvm and didn&#8217;t set the –XX:MaxPermSize [...]]]></description>
			<content:encoded><![CDATA[<p>As remarked on several places update 21 of 1.6 of the <del>sun</del> oracle jvm doesn&#8217;t work well when using lot of perm gem space.<br />
This was caused because oracle changed the vendors name of the jvm to oracle. Because of this eclipse launcher didn&#8217;t see it was the <del>sun</del> oracle jvm and didn&#8217;t set the –XX:MaxPermSize parameter.</p>
<p>Since 26st of july this issue is solved and oracle released a new version of the jvm. 1.6u21 -b07.<br />
So if you have the problem (only occurs on the windows variants) since you have updated to update 21 then you should update to build 07 (problem occurred in build06)</p>
<p>For more info see <a href="http://lt-rider.blogspot.com/2010/07/oracle-jvm-6u21-and-eclipse.html">this oracle-jvm-6u21-and-eclipse</a> post or <a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6969236">the bug</a></p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=435</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Subclipse &amp; JavaHL</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=428</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=428#comments</comments>
		<pubDate>Fri, 25 Jun 2010 09:48:13 +0000</pubDate>
		<dc:creator>RobbieC</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=428</guid>
		<description><![CDATA[Just installed the new Eclipse 3.6 (Helios) on my Ubuntu. Got some problems with Subclipse saying it could not find the JavaHL libraries (needed for interfacing from Java with Subversion). Problem is that the libraries are installed in /usr/lib/jni and the Eclipse java.library.path doesn&#8217;t point to that directory.
How to solve this? Add following line to [...]]]></description>
			<content:encoded><![CDATA[<p>Just installed the new Eclipse 3.6 (Helios) on my Ubuntu. Got some problems with Subclipse saying it could not find the JavaHL libraries (needed for interfacing from Java with Subversion). Problem is that the libraries are installed in /usr/lib/jni and the Eclipse java.library.path doesn&#8217;t point to that directory.</p>
<p>How to solve this? Add following line to your eclipse.ini:</p>
<p>-Djava.library.path=/usr/lib/jni/</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=428</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse shortcuts</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=418</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=418#comments</comments>
		<pubDate>Wed, 16 Jun 2010 08:03:04 +0000</pubDate>
		<dc:creator>Boris</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=418</guid>
		<description><![CDATA[Just found out really cool eclipse shortcut&#8230;
ctrl+3 you can use it to start any eclipse command&#8230;
While we are talking about shortCuts:
- ctrl+Shift+L to show all shortcuts
- alt + shift + x or alt + shift + d, t (j or something else) to start running or debugging current test (t) or java (j) app,&#8230;
- ctrl+1 [...]]]></description>
			<content:encoded><![CDATA[<p>Just <a href="http://unicase.blogspot.com/2010/06/hottest-hot-key_14.html">found</a> out really cool eclipse shortcut&#8230;<br />
ctrl+3 you can use it to start any eclipse command&#8230;</p>
<p>While we are talking about shortCuts:<br />
- ctrl+Shift+L to show all shortcuts<br />
- alt + shift + x or alt + shift + d, t (j or something else) to start running or debugging current test (t) or java (j) app,&#8230;<br />
- ctrl+1 to get quick fix menu</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=418</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ehcache UpdateChecker</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=414</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=414#comments</comments>
		<pubDate>Thu, 20 May 2010 10:07:18 +0000</pubDate>
		<dc:creator>JanM</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=414</guid>
		<description><![CDATA[We must be lucky Terracota sometimes releases new versions of ehcache.  This brought up the hidden feature of their automated update checker.   Each time you start an application with Ehcache enabled, it makes a connection to the terracotta webserver to check for a new version.  This feature is enabled by default!
We don&#8217;t need to check [...]]]></description>
			<content:encoded><![CDATA[<p>We must be lucky Terracota sometimes releases new versions of <a href="http://ehcache.org/">ehcache</a>.  This brought up the hidden feature of their automated update checker.   Each time you start an application with Ehcache enabled, it makes a connection to the terracotta webserver to check for a new version.  This feature is enabled by default!</p>
<p>We don&#8217;t need to check this each time, and we don&#8217;t want to send info to terracotta each time a developer runs a unit test that has a dependency on ehcache.</p>
<p>to disable it, edit your ehcache.xml:<br />
<code><br />
&lt;?xml version="1.0" encoding="UTF-8"?&gt;<br />
&lt;ehcache updateCheck="false"&gt;<br />
...<br />
</code></p>
<p>PS:  <a href="http://www.quartz-scheduler.org/">Quartz</a> also has this feature since version 1.7.2</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=414</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New version of Google spreadsheet</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=408</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=408#comments</comments>
		<pubDate>Tue, 13 Apr 2010 07:57:35 +0000</pubDate>
		<dc:creator>RobbyVD</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=408</guid>
		<description><![CDATA[Google has released a new version of Google spreadsheets for testing.
It looks as if a number of MS Excel UI features have been introduced to make the UI faster to work with.
An overview of the new features can be found at: http://docs.google.com/support/bin/answer.py?answer=174915
]]></description>
			<content:encoded><![CDATA[<p>Google has released a new version of Google spreadsheets for testing.<br />
It looks as if a number of MS Excel UI features have been introduced to make the UI faster to work with.<br />
An overview of the new features can be found at: http://docs.google.com/support/bin/answer.py?answer=174915</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=408</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Build-IT: Setting initial default values that remain after the form is cleared</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=372</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=372#comments</comments>
		<pubDate>Mon, 01 Feb 2010 15:26:05 +0000</pubDate>
		<dc:creator>KevinR</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=372</guid>
		<description><![CDATA[The following feature has been added to the GenericSelectorForm: setting initial default values and setting default values after the form is cleared.
This feature might come in handy when you want to have some default values entered when a selector is shown, and when you want these default values to be retained after the clear button [...]]]></description>
			<content:encoded><![CDATA[<p>The following feature has been added to the GenericSelectorForm: setting initial default values and setting default values after the form is cleared.</p>
<p>This feature might come in handy when you want to have some default values entered when a selector is shown, and when you want these default values to be retained after the clear button is clicked. Some similar features already exist (e.g. runFastProperties, @PropertyEvents, and the GenericSelectorFormWithReadOnlyFields class), but these don&#8217;t quite provide the desired functionality.</p>
<p>The new method is to add a GenericSelectorDefaultValuesProvider to your SelectorForm. This interface provides two methods:</p>
<p>    /**<br />
     * Sets default values after clear command is called<br />
     * @param formModel<br />
     */<br />
    void setDefaultValuesAfterClear(FormModel formModel);<br />
    /**<br />
     * Sets initial default values<br />
     * @param formModel<br />
     */<br />
    void setInitialDefaultValues(FormModel formModel);</p>
<p>You have to create a class which implements this interface, and set it on your selectorformDescriptor bean, like this:<br />
    <entry key="defaultValuesProvider"><br />
        <bean class="net.pearlchain.prl.ui.form.selector.SomeSelectorDefaultValuesProvider"/><br />
    </entry></p>
<p>Note:<br />
 &#8211; For setDefaultValuesAfterClear(FormModel): Create a new FormObject, set the default values on it and set that new formObject on the specified FormModel. If you use FormModelUtils, or if you set the value on the existing formObject, you might get problems with the revert-icon.<br />
 &#8211; For setInitialDefaultValues(FormModel): You can use whatever method you like. Either use FormModelUtils, or update the existing FormObject, or create a new one.</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=372</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Optimizing Tortoise SVN Cache</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=366</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=366#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:44:13 +0000</pubDate>
		<dc:creator>JanM</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=366</guid>
		<description><![CDATA[for all of those who are wondering what the TSVNCache.exe process is doing, and why the windows explorer is rather slow after installing Tortoise SVN.
By default, TortoiseSVN looks in every folder you open for SVN information.  It tries to get SVN info for all files in the folder you&#8217;re opening because it wants to show [...]]]></description>
			<content:encoded><![CDATA[<p>for all of those who are wondering what the TSVNCache.exe process is doing, and why the windows explorer is rather slow after installing Tortoise SVN.</p>
<p>By default, TortoiseSVN looks in every folder you open for SVN information.  It tries to get SVN info for all files in the folder you&#8217;re opening because it wants to show those nice svn status icons for each file.    But the directories with svn info are probably all in c:\projects (or similar).</p>
<p>You can configure TortoiseSVN which directories should be omitted when looking for SVN info.</p>
<ul>
<li>Right-click on folder or file and select &#8220;TortoiseSVN -&gt; Settings&#8230;</li>
<li>go to the <a title="TortoiseSVN manual" href="http://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-settings.html#tsvn-dug-settings-dia-context">Context Menu Settings</a> screen</li>
<li>insert all directories that contain no folders with SVN info:   I did a  &#8220;dir /B /AD c:\&#8221;  to get all the directories on my disk and removed c:\projects and c:\workspaces</li>
<li>optional: complain you can&#8217;t use &#8220;include paths&#8221; and &#8220;exclude paths&#8221; anymore, this was possible in <a title="blog post with similar info" href="http://www.paraesthesia.com/archive/2007/09/26/optimize-tortoise-svn-cache-tsvncache.exe-disk-io.aspx">previous versions</a> of TortoiseSVN</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=366</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>BigDecimals</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=342</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=342#comments</comments>
		<pubDate>Tue, 12 Jan 2010 10:31:58 +0000</pubDate>
		<dc:creator>Boris</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=342</guid>
		<description><![CDATA[Since our business didn&#8217;t want us to use floating points any more, but something more precise, we decided to start using BigDecimals instead of doubles.
Our calculations are actually fairly straight forward. Something like

private double calc&#40;double x, double y, double previous&#41;&#123;
    return previous * &#40;x/y&#41;;
&#125;

So I converted the code to BigDecimal (remark x [...]]]></description>
			<content:encoded><![CDATA[<p>Since our business didn&#8217;t want us to use floating points any more, but something more precise, we decided to start using BigDecimals instead of doubles.</p>
<p>Our calculations are actually fairly straight forward. Something like</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">double</span> calc<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> x, <span style="color: #000066; font-weight: bold;">double</span> y, <span style="color: #000066; font-weight: bold;">double</span> previous<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> previous <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span>x<span style="color: #339933;">/</span>y<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So I converted the code to BigDecimal (remark x and y are coming from somewhere else so they are still double (for now))</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">BigDecimal</span> calc<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> x, <span style="color: #000066; font-weight: bold;">double</span> y, <span style="color: #003399;">BigDecimal</span> previous<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> previous.<span style="color: #006633;">multiply</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigDecimal</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">divide</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigDecimal</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>&#8220;Ah quite easy&#8221; you would think, but when running this code I sometimes get a java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal result.<br />
This happens when, for example, we use x = 2 and y = 3. 2/3 is 0.666666666&#8230;. (endless). So BigDecimal doesn&#8217;t know what to do and gives a runTimeException.<br />
This means we should actually use some rounding method.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">BigDecimal</span> calc<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> x, <span style="color: #000066; font-weight: bold;">double</span> y, <span style="color: #003399;">BigDecimal</span> previous<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigDecimal</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">divide</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigDecimal</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span>,RoundingMode.<span style="color: #006633;">HALF_UP</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">multiply</span><span style="color: #009900;">&#40;</span>previous<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>So now we don&#8217;t get the ArithmeticException any more but the result with 2,3 and 1 now gives 1, while we expect somthing like 0.6666666666&#8230;7<br />
2/3 is 0.6&#8230; rounded this is 1. So this is still not what we wanted.<br />
What you can do now is:
<ul>
<li>define the scale you want to have after division (amount of decimals after comma)</li>
<li>Use a MathContext (and basically defining percision and rounding mode with that) </li>
</ul>
<p>Some examples:</p>
<table>
<th>
<td>2/3</td>
<td>2000/3</td>
<td>0.2/0.3</td>
</th>
<tr>
<td>scale = 5</td>
<td>0.66667</td>
<td>666.66667</td>
<td>0.66667</td>
</tr>
<tr>
<td>mathContext (presision=5)</td>
<td>0.66667</td>
<td>666.67</td>
<td>0.66667</td>
</tr>
<tr>
<td>only rounding</td>
<td>1</td>
<td>667</td>
<td>0.666666666666666728345723590286476750563174908436298048</td>
</tr>
</table>
<p>When using only the round we discover another problem: when converting double to BigDecimal the BigDecimal is not completely the number we meant to have. Because of this 0.2/0.3 seems quite exact but it is actually wrong. This is caused by the fact that 0.3 is actually 0.299999999999999988897769753748&#8230; this is caused by the nature of double values). So to be correct, we should/can actually also round the original starting numbers.</p>
<p>Since we also have a limited amount of numbers after the comma which are interesting for us, I ended up to convert every number before using it to a number with a certain scale. Then we don&#8217;t have to care any more about this scale or precision when multiplying and dividing (however still about the rounding method).<br />
So finally I got this method:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">BigDecimal</span> calc<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">double</span> x, <span style="color: #000066; font-weight: bold;">double</span> y, <span style="color: #003399;">BigDecimal</span> previous<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">BigDecimal</span> bigX <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigDecimal</span><span style="color: #009900;">&#40;</span>x<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setScale</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span>, RoundingMode.<span style="color: #006633;">HALF_UP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">BigDecimal</span> bigY <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BigDecimal</span><span style="color: #009900;">&#40;</span>y<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setScale</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span>, RoundingMode.<span style="color: #006633;">HALF_UP</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> bigX.<span style="color: #006633;">divide</span><span style="color: #009900;">&#40;</span>bigY,RoundingMode.<span style="color: #006633;">HALF_UP</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">multiply</span><span style="color: #009900;">&#40;</span>previous<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>One last thing:<br />
new BigDecimal(1).equals(new BigDecimal(1).setScale(10)) returns false.<br />
Basically we are comparing 1 and 1.0000000000 here. These two are not the same!</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=342</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Annotations and reflection: Retention</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=337</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=337#comments</comments>
		<pubDate>Tue, 22 Dec 2009 11:21:16 +0000</pubDate>
		<dc:creator>Youri De Bondt</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=337</guid>
		<description><![CDATA[The other day I tried to perform the following code:

public @interface MyAnn {
   String value();
}
@MyAnn(value = "foo")
public class MyClass {
}
..
MyClass.class.getAnnotation(MyAnn.class).value();

This gave me a NullPointerException because the annotation was not found.
I cursed, I googled, and I felt stupid for a whole day  
Later, I figured out it has something to do with retention. [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I tried to perform the following code:<br />
<code><br />
public @interface MyAnn {<br />
   String value();<br />
}</p>
<p>@MyAnn(value = "foo")<br />
public class MyClass {<br />
}<br />
..<br />
MyClass.class.getAnnotation(MyAnn.class).value();<br />
</code><br />
This gave me a NullPointerException because the annotation was not found.<br />
I cursed, I googled, and I felt stupid for a whole day <img src='http://javablog.pearlchain.net/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Later, I figured out it has something to do with <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/Retention.html">retention</a>. It&#8217;s an annotation which tells the VM how long the annotation has to be retained.</p>
<p>So the solution to my problem was just setting the right retention policy on my annotation:<br />
<code><br />
@Retention(Retention.RUNTIME)<br />
public @interface MyAnn {<br />
   String value();<br />
}<br />
</code><br />
<i>For more info refer to the javadoc: <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/Retention.html">http://java.sun.com/j2se/1.5.0/docs/api/java/lang/annotation/Retention.html</a><br />
Source: <a href="http://java.nullpointer.be/2009/12/annotations-using-reflection.html">http://java.nullpointer.be/2009/12/annotations-using-reflection.html</a></i></p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=337</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JAXB 2.1 and Jdk 6 problem</title>
		<link>http://javablog.pearlchain.net/wordpress/?p=331</link>
		<comments>http://javablog.pearlchain.net/wordpress/?p=331#comments</comments>
		<pubDate>Mon, 14 Dec 2009 11:50:35 +0000</pubDate>
		<dc:creator>StevenV</dc:creator>
				<category><![CDATA[Camel]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jaxb]]></category>
		<category><![CDATA[jdk]]></category>

		<guid isPermaLink="false">http://javablog.pearlchain.net/wordpress/?p=331</guid>
		<description><![CDATA[Jaxb is part of the jdk since jdk version 6. The earliest versions of the jdk 6 (update 1 till 3) have jaxb 2.0 included. The later versions of jdk 6 make use of jaxb 2.1.
Our pearlchain application makes use of camel which on its turn depends on jaxb version 2.1.  In order to be [...]]]></description>
			<content:encoded><![CDATA[<p>Jaxb is part of the jdk since jdk version 6. The earliest versions of the jdk 6 (update 1 till 3) have jaxb 2.0 included. The later versions of jdk 6 make use of jaxb 2.1.</p>
<p>Our pearlchain application makes use of camel which on its turn depends on jaxb version 2.1.  In order to be compatible with java version 5 we&#8217;ve added a maven dependency to this jaxb 2.1 jar. When running the application with java 5 we&#8217;ve encountered no problems however when running the application with jdk 6 some developers got the following error :</p>
<p><em>java.lang.LinkageError: JAXB 2.0 API is being loaded from the bootstrap classloader, but this RI (from jar:file:/C:/Documents%20and%20Settings/steven/.m2/repository/com/sun/xml/bind/jaxb-impl/2.1.10/jaxb-impl-2.1.10.jar!/com/sun/xml/bind/v2/model/impl/ModelBuilder.class) needs 2.1 API. Use the endorsed directory mechanism to place jaxb-api.jar in the bootstrap classloader. (See http://java.sun.com/j2se/1.5.0/docs/guide/standards/)</em></p>
<p>Those developers were running the application with an earlier version of jdk 6 (update 1 -3).<br />
There are 2 solutions:</p>
<ul>
<li>update jdk6 to at least jdk update 4 release</li>
<li>use the guideline in the error message :  override jaxb 2.0 and put jaxb 2.1 jar before rt.jar in bootclasspath. See  <em><a title="http://java.sun.com/j2se/1.5.0/docs/guide/standards/" href="http://java.sun.com/j2se/1.5.0/docs/guide/standards/">http://java.sun.com/j2se/1.5.0/docs/guide/standards/</a> </em>for more details about Endorsed Standards Override Mechanism.</li>
</ul>
<p>We&#8217;ve chosen the first solution. However keep the second solution in mind when you can&#8217;t change the jdk6 to a more recent update release.</p>
<p>Cheers,</p>
<p>Steven</p>
]]></content:encoded>
			<wfw:commentRss>http://javablog.pearlchain.net/wordpress/?feed=rss2&amp;p=331</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
