<?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>Chris Johnston &#187; Java</title>
	<atom:link href="http://www.fuzzylizard.com/archives/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.fuzzylizard.com</link>
	<description>Web development and design with a little VFX thrown in for fun</description>
	<lastBuildDate>Mon, 14 Sep 2009 23:06:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Note to self; Mockito cannot stub final methods</title>
		<link>http://www.fuzzylizard.com/archives/2008/08/23/973/</link>
		<comments>http://www.fuzzylizard.com/archives/2008/08/23/973/#comments</comments>
		<pubDate>Sat, 23 Aug 2008 10:56:24 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Frameworks]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/?p=973</guid>
		<description><![CDATA[I realize this is clearly stated on the Mockito website, but it caught myself and my pair up for a little while. we were trying to stub out a ResourceBundle using Mockito and found that the unit test kept trying to find a concrete implementation of the ResourceBundle. The reason, we figured out is that [...]]]></description>
			<content:encoded><![CDATA[<p>I realize this is clearly stated on <a href="http://code.google.com/p/mockito/">the Mockito website</a>, but it caught myself and my pair up for a little while. we were trying to stub out a <code>ResourceBundle</code> using Mockito and found that the unit test kept trying to find a concrete implementation of the <code>ResourceBundle</code>. The reason, we figured out is that the <code>ResourceBundle.getString()</code> method is final and Mockito cannot mock or stub final methods. Something to keep in mind when working with this mocking framework.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2008/08/23/973/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back to Java</title>
		<link>http://www.fuzzylizard.com/archives/2008/08/21/969/</link>
		<comments>http://www.fuzzylizard.com/archives/2008/08/21/969/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 12:14:45 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/?p=969</guid>
		<description><![CDATA[I am on a new project located in Melbourne, Australia. This time I am back to the world of Java. Some of the new to me technology includes Hibernate Validations, JAXB, and JPA. It looks like an interesting project with lots of XP practices being followed. Everyone is pairing, which will be a nice change [...]]]></description>
			<content:encoded><![CDATA[<p>I am on a new project located in Melbourne, Australia. This time I am back to the world of Java. Some of the new to me technology includes Hibernate Validations, JAXB, and JPA. It looks like an interesting project with lots of XP practices being followed. Everyone is pairing, which will be a nice change for me as I have yet to be on a project where pairing was being followed. I am going to attempt to post entries several times a week about the stuff that I am learning.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2008/08/21/969/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Capturing Java Stacktrace as a String</title>
		<link>http://www.fuzzylizard.com/archives/2008/08/09/963/</link>
		<comments>http://www.fuzzylizard.com/archives/2008/08/09/963/#comments</comments>
		<pubDate>Sun, 10 Aug 2008 03:28:20 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/?p=963</guid>
		<description><![CDATA[Here is a little code snippet for a method that will capture an Exception&#8217;s stacktrace as a string so you can output it on the command line or in a simple log statement.

]]></description>
			<content:encoded><![CDATA[<p>Here is a little code snippet for a method that will capture an Exception&#8217;s stacktrace as a string so you can output it on the command line or in a simple log statement.</p>
<p><script src="http://gist.github.com/4716.js"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2008/08/09/963/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Wicket Phone Book and Maven 2</title>
		<link>http://www.fuzzylizard.com/archives/2008/01/21/919/</link>
		<comments>http://www.fuzzylizard.com/archives/2008/01/21/919/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 06:07:41 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Frameworks]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Wicket]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2008/01/21/919/</guid>
		<description><![CDATA[This evening I tried to download and setup the wicket-phonebook example in Eclipse. The application uses Maven2, something I have not had a lot of experience working with. In the root directory of wicket-phonebook, there is a script called Eclipse.sh which configures everything as an Eclipse project. It also downloads into the Maven2 repository almost [...]]]></description>
			<content:encoded><![CDATA[<p>This evening I tried to download and setup the <a href="http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-phonebook">wicket-phonebook</a> example in Eclipse. The application uses Maven2, something I have not had a lot of experience working with. In the root directory of wicket-phonebook, there is a script called Eclipse.sh which configures everything as an Eclipse project. It also downloads into the Maven2 repository almost all the dependencies.</p>
<p>However, there are two steps that are not done:</p>
<ol>
<li>Set up the M2_REPO environment variable in Eclipse</li>
<li>Download and install JTA</li>
</ol>
<p>For the first, I found the following command:</p>
<pre>
mvn -Declipse.workspace=
<path_to_workspace> eclipse:add-maven-repo
</path_to_workspace></pre>
<p>And for the second problem, I found the answer on <a href="http://www.jugpadova.it/articles/2005/11/26/maven-2-spring-and-jta-depencies">JUGPadova website.</a> In short, the problem has to do with Sun&#8217;s licensing of some of their J2EE jar files. Once I downloaded the JTA.1.0.1B.jar file, the following command put it in place and took care of all remaining errors in my Eclipse project.</p>
<pre>
mvn install:install-file \
  -Dfile=./jta-1_0_1B-classes.zip \
  -DgroupId=javax.transaction \
  -DartifactId=jta -Dversion=1.0.1B \
  -Dpackaging=jar
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2008/01/21/919/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Immutable Objects</title>
		<link>http://www.fuzzylizard.com/archives/2007/02/19/867/</link>
		<comments>http://www.fuzzylizard.com/archives/2007/02/19/867/#comments</comments>
		<pubDate>Tue, 20 Feb 2007 04:51:08 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Thoughts]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2007/02/19/867/</guid>
		<description><![CDATA[I am back in Chicago for more training. This time it is Object Bootcamp. One thing that we touched on today was the idea of immutable objects. Put simply, this means that the state of an object cannot be changed. From a conceptual point of view, this makes a lot of sense. If you have [...]]]></description>
			<content:encoded><![CDATA[<p>I am back in Chicago for more training. This time it is Object Bootcamp. One thing that we touched on today was the idea of immutable objects. Put simply, this means that the state of an object cannot be changed. From a conceptual point of view, this makes a lot of sense. If you have a <code>Money</code> and you create a new object worth $5.00 there is no way that you should be able to change that into $2.00. If you want to have $2.00, you need to create a new object since in reality you would no longer have $5.00.</p>
<p>The trick comes when you need to scale this up to more complex domain objects which have more then one or two attributes. So for example, how does this translate when you have a Class that represents a person. If that person&#8217;s name changes, does that make them a new person? Probably not. However, if their address changes, and the address is represented by an object composited within <code>Person</code>, then you can make a very strong argument that it represents a new address. Therefore, a new <code>Address</code> object needs to be instantiated.</p>
<p>The same argument could be made for a person&#8217;s email address or phone number.</p>
<p>This idea becomes important when you think about creating multi-threaded systems. Having all of your domain objects immutable means that they are all read-only. This means that you really do not have any shared resources between threads and it reduces the complexity of the entire application. </p>
<p>I am still thinking all of this through and have yet to try any of it on a real life application. In theory though it makes a lot of sense, but I am not sure how well it will work in practice. I think there will always be some information in domain model objects, or any class for that matter, that it makes sense to have change and thus violates this idea of having all objects be immutable.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2007/02/19/867/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Problems with Log4j</title>
		<link>http://www.fuzzylizard.com/archives/2006/12/19/842/</link>
		<comments>http://www.fuzzylizard.com/archives/2006/12/19/842/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 00:23:44 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/12/19/842/</guid>
		<description><![CDATA[The testing team has discovered an odd problem related to Log4j. While system testing our application, they decided to delete the log file. The result was that Log4j did not create a new log file the next time there was a log request. They had to restart the application in order for Log4j to create [...]]]></description>
			<content:encoded><![CDATA[<p>The testing team has discovered an odd problem related to Log4j. While system testing our application, they decided to delete the log file. The result was that Log4j did not create a new log file the next time there was a log request. They had to restart the application in order for Log4j to create a new file and start logging to it.</p>
<p>I have scoured the web to find a solution to this and have come up empty handed. I basically need a solution that configures Log4j to, when the current log file is deleted, create a new file. Anyone have any ideas?</p>
<p>So far my best advice has been: don&#8217;t delete the log file <img src='http://www.fuzzylizard.com/wp-includes/images/smilies/icon_razz.gif' alt=':-P' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2006/12/19/842/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Eclipse and the hunt for soft tabs</title>
		<link>http://www.fuzzylizard.com/archives/2006/12/11/840/</link>
		<comments>http://www.fuzzylizard.com/archives/2006/12/11/840/#comments</comments>
		<pubDate>Tue, 12 Dec 2006 03:52:03 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/12/11/840/</guid>
		<description><![CDATA[If I want to change the default behaviour for using soft tabs&#8211;using spaces instead of tabs when I press the tab key&#8211;in NetBeans, I only need to make the change in one place. If I want to do the same in jEdit, I only need to set it once. If I want to set soft [...]]]></description>
			<content:encoded><![CDATA[<p>If I want to change the default behaviour for using soft tabs&#8211;using spaces instead of tabs when I press the tab key&#8211;in NetBeans, I only need to make the change in one place. If I want to do the same in jEdit, I only need to set it once. If I want to set soft tabs in Eclipse, I need to change it all over the place.</p>
<p>I was working on an Ant build script today in Eclipse and wanted to change the default editor behaviour to use spaces instead of tabs. So I wandered into the Preferences section. I know the setting is not going to be under Java, so I try the General tab, no luck. Finally, I try the &#8220;Web and XML&#8221; tab. Sure enough, there is a tab for XML files under which I can set the &#8220;Indent using spaces&#8221; option and press apply. </p>
<p>I then go back to editing my build file and it is still using tabs. Apparently, to Eclipse, a build file is not an XML file. So back into the preferences I go. This time I see the Ant tab and am able to set it to use spaces there.</p>
<p>Something as fundamental to programming as the option of using Tabs or Spaces should be obvious and easy to set for every editor. This is one area that NetBeans has Eclipse beat hands down. It is very easy to set editor styles in NetBeans. Granted, Eclipse&#8217;s editor styles and setting are more powerful, but they are also incredibly complex and confusing. </p>
<p>Every time I go looking to set spaces instead of tabs for the Java editor, it takes me at least a half hour of searching and hunting. This is because it is not even an option. Instead, it needs to be configured via the Code Style Formatter by either creating a new style or modifying one of the default styles.</p>
<p>What is the saying, &#8220;Make the simple things simple and the complex things possible&#8221;? This is one area that Eclipse makes what should be an easy thing incredibly complex. i think this is Eclipse&#8217;s biggest downfall, it simply is not simple to use. Nothing is intuitive about the application. True, it is very powerful and configurable. I guess that it is why it is the number one IDE, but simple it is not.</p>
<p>I use Eclipse all the time, but for new programmers I always recommend NetBeans because it is simple to use and easy to start working with.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2006/12/11/840/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Two Simple Ant build Tricks</title>
		<link>http://www.fuzzylizard.com/archives/2006/11/26/835/</link>
		<comments>http://www.fuzzylizard.com/archives/2006/11/26/835/#comments</comments>
		<pubDate>Mon, 27 Nov 2006 00:27:18 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Application Development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/11/26/835/</guid>
		<description><![CDATA[h3. Ant build scripts and NetBeans
Here is a small trick for working with NetBeans and Ant build files. One problem with NetBeans is that if your source code already has a build file, NetBeans will use that build file. Unfortunately, when you do this, you loose a fair bit of NetBeans functionality like the ability [...]]]></description>
			<content:encoded><![CDATA[<p>h3. Ant build scripts and NetBeans</p>
<p>Here is a small trick for working with NetBeans and Ant build files. One problem with NetBeans is that if your source code already has a build file, NetBeans will use that build file. Unfortunately, when you do this, you loose a fair bit of NetBeans functionality like the ability to run individual JUnit test classes. You can test the entire application, assuming that you have setup a JUnit test target in your build file, but you cannot run a single test. This little trick gets around that.</p>
<p>I have to start by saying that this trick is fairly obvious. The trick is to rename the build file. Instead of calling it @build.xml@, call it something else. This will allow you to setup your project, in NetBeans, as a &#8220;project With Existing Sources&#8221; instead of a &#8220;With Existing Build Script&#8221;. This means that NetBeans will create its own build script and give you the full functionality and power of NetBeans.</p>
<p>h3. Refactoring Build Scripts</p>
<p>If you have an application that is divided into several different projects that you would like to manage with separate build scripts, but not necessarily different build scripts, then this trick will work. The idea is to use the &#8220;DRY(Don&#8217;t Repeat Yourself)&#8221;:http://en.wikipedia.org/wiki/Don&#8217;t_repeat_yourself principle. Take all the parts that are the same in the build scripts and put them into a separate file. Then import that file into the build scripts for each project.</p>
<p>The advantage is now when you have to make changes, you only need to go to one file. You no longer need to edit one file and then copy-paste those changes into several more files. This saves you from copy-paste errors or forgetting to change a file.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2006/11/26/835/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Open Sourced</title>
		<link>http://www.fuzzylizard.com/archives/2006/11/13/829/</link>
		<comments>http://www.fuzzylizard.com/archives/2006/11/13/829/#comments</comments>
		<pubDate>Mon, 13 Nov 2006 17:19:53 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Source]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/11/13/829/</guid>
		<description><![CDATA[Sun has open sourced part of Java under the GPL(GNU Public Licence) v2 license.
bq. The initial release today will include the HotSpot runtime, javac compiler, JavaHelp, and Sun&#8217;s Java ME implementation. The rest of Java will be released under GPLv2 early next year. (&#8220;Javalobby.org&#8221;:http://www.javalobby.org/java/forums/t84244.html)
The interesting part of this release is the inclusion of a Classpath [...]]]></description>
			<content:encoded><![CDATA[<p>Sun has open sourced part of Java under the GPL(GNU Public Licence) v2 license.</p>
<p>bq. The initial release today will include the HotSpot runtime, javac compiler, JavaHelp, and Sun&#8217;s Java ME implementation. The rest of Java will be released under GPLv2 early next year. (&#8220;Javalobby.org&#8221;:http://www.javalobby.org/java/forums/t84244.html)</p>
<p>The interesting part of this release is the inclusion of a Classpath Exception which</p>
<p>bq. permits you to link your code to open source Java without forcing your code to fall under the GPL as well. (&#8220;Javalobby.org&#8221;:http://www.javalobby.org/java/forums/t84256.html)</p>
<p>In addition to the open source GPLv2 license, Sun is going to dual license Java so that commercial entities can use it without having to worry about the viral nature of the GPL, even though the Classpath Exception is, as I understand it, suppose to handle this.</p>
<p>In order to help us with this transition, &#8220;Sun has set up an FAQ page&#8221;:http://www.sun.com/software/opensource/java/. In addition, there is also the &#8220;OpenJDK website&#8221;:https://openjdk.dev.java.net/.</p>
<p>The following links have more information:</p>
<p>* &#8220;Open Source Java Editorial on Java.net&#8221;:http://today.java.net/pub/a/today/2006/11/13/open-source-java-editorial.html<br />
* &#8220;Java GPLed on the O&#8217;reilly onJava.com website&#8221;:http://www.oreillynet.com/onjava/blog/2006/11/java_gpled_1.html?CMP=OTC-FP2116136014&#038;ATT=Java+GPLed</p>
<p>As I find more links of interest I will post them here.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2006/11/13/829/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The nuances of Java for-each loop</title>
		<link>http://www.fuzzylizard.com/archives/2006/11/07/823/</link>
		<comments>http://www.fuzzylizard.com/archives/2006/11/07/823/#comments</comments>
		<pubDate>Wed, 08 Nov 2006 03:18:25 +0000</pubDate>
		<dc:creator>Chris Johnston</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.fuzzylizard.com/archives/2006/11/07/823/</guid>
		<description><![CDATA[Java.net has posted an article detailing some of the &#8220;nuances of Java&#8217;s @for-each@ loop&#8221;:http://today.java.net/pub/a/today/2006/11/07/nuances-of-java-5-for-each-loop.html. This loop is a new addition to Java 5 and, in my opinion, one of the more welcomed and helpful additions. At least I like it a lot, it definitely saves you typing a fair bit of code.
bq. This article is [...]]]></description>
			<content:encoded><![CDATA[<p>Java.net has posted an article detailing some of the &#8220;nuances of Java&#8217;s @for-each@ loop&#8221;:http://today.java.net/pub/a/today/2006/11/07/nuances-of-java-5-for-each-loop.html. This loop is a new addition to Java 5 and, in my opinion, one of the more welcomed and helpful additions. At least I like it a lot, it definitely saves you typing a fair bit of code.</p>
<p>bq. This article is an in-depth examination of one of the simplest but most pleasing features in Java 5.0&#8211;the @for-each@ loop. I present eleven short items discussing various nuances of usage, pitfalls to be aware of, and possible optimizations surrounding the use of the @for-each@ loop. In the first section, I discuss what kind of iterations are possible with the @for-each@. The next section illustrates common programming errors in using the @for-each@ loop. The final section shows how to write new classes that can be used as targets of a @for-each@ loop. I also talk about advanced implementations that allow multiple iterable views; lazily construct objects just in time for iteration; and enable possible generic algorithm and compiler optimizations of the @for-each@ loop.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.fuzzylizard.com/archives/2006/11/07/823/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
