<?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>TylerBurton.ca &#187; Java</title>
	<atom:link href="http://www.tylerburton.ca/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tylerburton.ca</link>
	<description></description>
	<lastBuildDate>Tue, 10 Jan 2012 04:41:43 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>The Linux Experiment Post Roundup</title>
		<link>http://www.tylerburton.ca/2012/01/the-linux-experiment-post-roundup/</link>
		<comments>http://www.tylerburton.ca/2012/01/the-linux-experiment-post-roundup/#comments</comments>
		<pubDate>Tue, 10 Jan 2012 01:43:17 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Created by Tyler Burton]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[The Linux Experiment]]></category>
		<category><![CDATA[amd]]></category>
		<category><![CDATA[ati]]></category>
		<category><![CDATA[distributions]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[games]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Netbeans]]></category>
		<category><![CDATA[oracle]]></category>
		<category><![CDATA[red alert]]></category>
		<category><![CDATA[sun]]></category>
		<category><![CDATA[ubuntu]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=656</guid>
		<description><![CDATA[There has been quite a bit of activity on The Linux Experiment over the past little while. Check out the site here or quickly jump to the post that I wrote below. Big distributions, little RAM 3 How do the &#8216;big time&#8217; distributions handle on constrained hardware? Take a look. How to install sun-java6-jdk and [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>There has been quite a bit of activity on The Linux Experiment over the past little while. Check out the site <a href="http://www.thelinuxexperiment.com">here</a> or quickly jump to the post that I wrote below.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/big-distributions-little-ram-3/">Big distributions, little RAM 3</a></h2>
<p>How do the &#8216;big time&#8217; distributions handle on constrained hardware? Take a look.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/how-to-install-sun-java6-jdk-and-netbeans-in-ubuntu-11-10/">How to install sun-java6-jdk and Netbeans in Ubuntu 11.10</a></h2>
<p>A simple process to install the <em>official</em> <del>Sun</del>Oracle Java JDK and Netbeans IDE in the latest Ubuntu.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/ubuntu-11-10s-wifi-crashes-my-router/">Ubuntu 11.10′s WiFi crashes my router</a></h2>
<p>The new Ubuntu release is pretty good. Unfortunately it also causes my router to crash.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/gentoo-a-k-a-compiling/">Gentoo (A.K.A. “Compiling!”)</a></h2>
<p>My first post for the second Linux Experiment where I speak about my Gentoo first impressions.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/how-to-enable-rebootshutdown-in-kde-on-gentoo/">How to enable reboot/shutdown in KDE on Gentoo</a></h2>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/closed-source-amdati-drivers-wireless-networking-and-flash-in-gentoo/">Closed source AMD/ATI drivers, wireless networking and Flash in Gentoo</a></h2>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/how-to-update-your-whole-gentoo-system/">How to update your (whole) Gentoo system</a></h2>
<p>A trio of small posts that walk new Gentoo users through setting up and doing some basic things in their new desktop.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/how-to-play-red-alert-2-on-linux/">How to play Red Alert 2 on Linux</a></h2>
<p>I managed to get this classic game to run great on Linux. It even includes a bit of a hack that allows you to play LAN games. I don&#8217;t think you can even do that on Windows any more.</p>
<h2><a href="http://thelinuxexperiment.com/guinea-pigs/tyler-b/oh-gentoo/">Oh Gentoo</a></h2>
<p>My final post of the second Linux Experiment. Includes my conclusions on running Gentoo as a day-to-day desktop system.</p>
<div class="shr-publisher-656"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2012/01/the-linux-experiment-post-roundup/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android development in Netbeans</title>
		<link>http://www.tylerburton.ca/2011/06/android-development-in-netbeans/</link>
		<comments>http://www.tylerburton.ca/2011/06/android-development-in-netbeans/#comments</comments>
		<pubDate>Sat, 25 Jun 2011 01:20:45 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Netbeans]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=611</guid>
		<description><![CDATA[So you want to do Android development but you hate Eclipse? Well fear not, there is another IDE that you can use to meet your mobile development needs. This is a quick guide, mostly for my reference later, on how to setup an Android development environment in Netbeans. 1. Download and install the Android SDK [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>So you want to do Android development but you hate <a href="http://eclipse.org/">Eclipse</a>? Well fear not, there is another IDE that you can use to meet your mobile development needs. This is a quick guide, mostly for my reference later, on how to setup an Android development environment in Netbeans.</p>
<h3>1. Download and install the Android SDK and Netbeans IDE like normal</h3>
<p>Pretty self-explanatory just grab the installers from <a href="http://developer.android.com/sdk/index.html">here</a> and <a href="http://netbeans.org/">here</a> respectively.</p>
<h3>2. Download and install the Android plugin for Netbeans</h3>
<p>The plugin to use is <em>nbandroid</em> and the easiest way to get it is to download it from right within Netbeans. First add the update xml (<a href="http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml">http://kenai.com/projects/nbandroid/downloads/download/updatecenter/updates.xml</a>) to Netbeans.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2011/06/AddPlugin.jpg"><img class="aligncenter size-medium wp-image-617" title="AddPlugin" src="http://www.tylerburton.ca/files/wordpress/2011/06/AddPlugin-300x121.jpg" alt="" width="300" height="121" /></a></p>
<p>Then simply install the plugin from the refreshed list of available ones.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2011/06/InstallPlugin.jpg"><img class="aligncenter size-medium wp-image-618" title="InstallPlugin" src="http://www.tylerburton.ca/files/wordpress/2011/06/InstallPlugin-300x50.jpg" alt="" width="300" height="50" /></a></p>
<h3>3. Create an Android project</h3>
<p>Just like you would create any other project in Netbeans. This will prompt you that you need to set up the location of the SDK. This can be done through the <em>Manage Android SDK</em> button.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2011/06/SDKLocation.jpg"><img class="aligncenter size-medium wp-image-619" title="SDKLocation" src="http://www.tylerburton.ca/files/wordpress/2011/06/SDKLocation-300x78.jpg" alt="" width="300" height="78" /></a></p>
<p>Once created the project should be more or less good to go. Don&#8217;t worry if you get an error about a missing file <em>R.java</em>, this file will be automatically generated for your when you build the project the first time.</p>
<h3>4. Profit?</h3>
<p>That&#8217;s pretty much it. Now when you click run it will build and deploy your application to the emulator just like it does in regular old Eclipse.</p>
<div class="shr-publisher-611"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2011/06/android-development-in-netbeans/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically load a jar at runtime</title>
		<link>http://www.tylerburton.ca/2011/06/dynamically-load-a-jar-at-runtime/</link>
		<comments>http://www.tylerburton.ca/2011/06/dynamically-load-a-jar-at-runtime/#comments</comments>
		<pubDate>Mon, 13 Jun 2011 01:10:48 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[jar]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=607</guid>
		<description><![CDATA[How to dynamical load jar files at runtime]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>A short post but I figured I would throw it up here before I lose my code. There are a couple of different ways that you can load jar&#8217;d code at runtime but here is a simple solution that I found to work very easily.</p>
<pre>
       File myJar = new File("myJar.jar");
       URL url = myJar.toURI().toURL();

       Class<?>[] parameters = new Class[]{URL.class};

        URLClassLoader sysLoader = (URLClassLoader)ClassLoader.getSystemClassLoader();
        Class<?> sysClass = URLClassLoader.class;
        try
        {
            Method method = sysClass.getDeclaredMethod("addURL", parameters);
            method.setAccessible(true);
            method.invoke(sysLoader,new Object[]{ url });

            Constructor<?> cs = ClassLoader.getSystemClassLoader().loadClass("com.example.MyClass").getConstructor();
            MyInterface instance = (MyInterface)cs.newInstance();
            instance.someFunction();
        }
        catch(Exception ex)
        {
            System.err.println(ex.getMessage());
        }
</pre>
<p>In the code example above the jar at the location pointed to by the <i>url</i> object is dynamically loaded and an instance of the class <i>com.example.MyClass</i> is created that conforms to a known interface <i>MyInterface</i>. This could be used in a situation where you are loading plugins that use a common interface example.</p>
<div class="shr-publisher-607"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2011/06/dynamically-load-a-jar-at-runtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a GStreamer powered Java media player</title>
		<link>http://www.tylerburton.ca/2011/03/create-a-gstreamer-powered-java-media-player/</link>
		<comments>http://www.tylerburton.ca/2011/03/create-a-gstreamer-powered-java-media-player/#comments</comments>
		<pubDate>Mon, 14 Mar 2011 02:18:08 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[GStreamer]]></category>
		<category><![CDATA[media player]]></category>
		<category><![CDATA[mp3]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=593</guid>
		<description><![CDATA[For something to do I decided to see if I could create a very simple Java media player. After doing some research, and finding out that the Java Media Framework was no longer in development, I decided to settle on GStreamer to power my media player. GStreamer for the uninitiated is a very powerful multimedia [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>For something to do I decided to see if I could create a very simple Java media player. After doing some research, and finding out that the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Java_Media_Framework">Java Media Framework</a> was no longer in development, I decided to settle on <a href="http://gstreamer.freedesktop.org/">GStreamer</a> to power my media player.</p>
<p><a href="https://secure.wikimedia.org/wikipedia/en/wiki/Gstreamer">GStreamer</a> for the uninitiated is a very powerful multimedia framework that offers both low-level pipeline building as well as high-level playback abstraction. What&#8217;s nice about GStreamer, besides being completely open source, is that it presents a unified API no matter what type of file it is playing. For instance if the user only has the free, high quality GStreamer <em>codecs</em> installed, referred to as the <em>good</em> plugins, then the API will only play those files. If however the user installs the other plugins as well, be it the <em>bad</em> or <em>ugly</em> sets, the API remains the same and thus you don&#8217;t need to update your code. Unfortunately being a C library this approach does have some drawbacks, notably the need to include the <a href="https://secure.wikimedia.org/wikipedia/en/wiki/Java_Native_Access">JNA</a> jar as well as the system specific libraries. This approach can be considered similar to how <a href="http://www.tylerburton.ca/2010/09/hash-verifier-0-3-0-0-a-k-a-the-swt-re-write/">SWT</a> works.</p>
<p><strong>Setup</strong></p>
<p>Assuming that you already have a Java development environment, the first thing you&#8217;ll need is to install GStreamer. On Linux odds are you already have it, unless you are running a rather stripped down distro or don&#8217;t have many media players installed (both <a href="http://projects.gnome.org/rhythmbox/">Rhythmbox</a> and <a href="http://banshee.fm/">Banshee</a> use GStreamer). If you don&#8217;t it should be pretty straight forward to install along with your choice of plugins. On Windows you&#8217;ll need to head over to <a href="https://code.google.com/p/ossbuild/">ossbuild</a> where they have downloadable installers.</p>
<p>The second thing you&#8217;ll need is gstreamer-java which you can grab over at their website <a href="https://code.google.com/p/gstreamer-java/">here</a>. You&#8217;ll need to download both gstreamer-java-1.4.jar and jna-3.2.4.jar. Both might contain some extra files that you probably don&#8217;t need and can prune out later if you&#8217;d like. Setup your development environment so that both of these jar files are in your build path.</p>
<p><strong>Simple playback</strong></p>
<p>GStreamer offers highly abstracted playback engines called PlayBins. This is what we will use to actually play our files. Here is a very simple code example that demonstrates how to actually make use of a PlayBin:</p>
<pre>public static void main(String[] args) {
     args = Gst.init("MyMediaPlayer", args);

     Playbin playbin = new PlayBin("AudioPlayer");
     playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
     playbin.setInputFile("song.mp3");

     playbin.setState(State.PLAYING);
     Gst.main();
     playbin.setState(State.NULL);
}</pre>
<p>So what does it all mean?</p>
<pre>public static void main(String[] args) {
     args = Gst.init("MyMediaPlayer", args);</pre>
<p>The above line takes the incoming command line arguments and passes them to the Gst.init function and returns a new set of arguments. If you have ever done any <a href="http://www.gtk.org/">GTK+</a> programming before this should be instantly recognizable to you. Essentially what GStreamer is doing is grabbing, and removing, any GStreamer specific arguments before your program will actually process them.</p>
<pre>     Playbin playbin = new PlayBin("AudioPlayer");
     playbin.setVideoSink(ElementFactory.make("fakesink", "videosink"));
     playbin.setInputFile("song.mp3");
</pre>
<p>The first line of code requests a standard &#8220;AudioPlayer&#8221; PlayBin. This PlayBin is built right into GStreamer and automatically sets up a default pipeline for you. Essentially this lets us avoid all of the low-level craziness that we would have to normally deal with if we were starting from scratch.</p>
<p>The next line sets the PlayBin&#8217;s VideoSink, think of sinks as output locations, to a &#8220;fakesink&#8221; or null sink. The reason we do this is because PlayBin&#8217;s can play both audio and video. For the purposes of this player we only want audio playback so we automatically redirect all video output to the &#8220;fakesink&#8221;.</p>
<p>The last line is pretty straight forward and just tells GStreamer what file to play.</p>
<pre>     playbin.setState(State.PLAYING);
     Gst.main();
     playbin.setState(State.NULL);
</pre>
<p>Finally with the above lines of code we tell the PlayBin to actually start playing and then enter the GStreamer main loop. This loop continues for the duration. The last line is used to reset the PlayBin state and do some cleanup.</p>
<p><strong>Bundle it with a quick GUI</strong></p>
<p>To make it a little more friendly I wrote a very quick GUI to wrap all of the functionality with. The download links for that (binary only package), as well as the source (all package) is below. And there you have it: a very simple cross-platform media player that will playback pretty much anything you throw at it.</p>
<table border="1">
<tbody>
<tr>
<td></td>
<td><strong>Binary Only Package</strong></td>
<td><strong>All Package</strong></td>
</tr>
<tr>
<td><strong>File name:</strong></td>
<td>my_media_player_binary.zip</td>
<td>my_media_player_all.zip</td>
</tr>
<tr>
<td><strong>File hashes:</strong></td>
<td style="text-align: center;" colspan="2"><a href="http://www.tylerburton.ca/files/hashes/my_media_player_march_13_2011.hashes.txt" target="_blank">Download Here</a></td>
</tr>
<tr>
<td><strong>GPG signature:</strong></td>
<td><a href="http://www.tylerburton.ca/files/sigs/my_media_player_13_2011_binary.zip.sig">Download Here</a></td>
<td><a href="http://www.tylerburton.ca/files/sigs/my_media_player_march_13_2011_all.zip.sig">Download Here</a></td>
</tr>
<tr>
<td><strong>Screenshots:</strong></td>
<td><a href="http://www.tylerburton.ca/files/wordpress/2011/03/MyMediaPlayerWindows.jpg"><img class="aligncenter size-medium wp-image-597" title="MyMediaPlayerWindows" src="http://www.tylerburton.ca/files/wordpress/2011/03/MyMediaPlayerWindows-300x95.jpg" alt="" width="200" height="63" /></a></td>
<td><a href="http://www.tylerburton.ca/files/wordpress/2011/03/MyMediaPlayerLinux.jpg"><img class="aligncenter size-medium wp-image-599" title="MyMediaPlayerLinux" src="http://www.tylerburton.ca/files/wordpress/2011/03/MyMediaPlayerLinux-300x104.jpg" alt="" width="200" height="69" /></a></td>
</tr>
<tr>
<td><strong>Version:</strong></td>
<td style="text-align: center;" colspan="2">March 13, 2011</td>
</tr>
<tr>
<td><strong>File size:</strong></td>
<td>1.5MB</td>
<td>1.51MB</td>
</tr>
<tr>
<td><strong>File download:</strong></td>
<td><a href="http://www.tylerburton.ca/files/apps/my_media_player_13_2011_binary.zip">Download Here</a></td>
<td><a href="http://www.tylerburton.ca/files/apps/my_media_player_march_13_2011_all.zip">Download Here</a></td>
</tr>
</tbody>
</table>
<div class="shr-publisher-593"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2011/03/create-a-gstreamer-powered-java-media-player/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hash Verifier 0.3.0.1 (Java Web Start)</title>
		<link>http://www.tylerburton.ca/2010/10/hash-verifier-0-3-0-1-java-web-start/</link>
		<comments>http://www.tylerburton.ca/2010/10/hash-verifier-0-3-0-1-java-web-start/#comments</comments>
		<pubDate>Sun, 24 Oct 2010 23:45:48 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Created by Tyler Burton]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[hash verifier]]></category>
		<category><![CDATA[Java Web Start]]></category>
		<category><![CDATA[SWT]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=451</guid>
		<description><![CDATA[Java Web Start is a technology that allows easy deployment of Java based software through a web browser. The advantages of this framework are numerous but one nice thing is that it allows you far more freedom then the completely sandboxed Java applet. In this post I will detail how I converted my Hash Verifier [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><a href="http://en.wikipedia.org/wiki/Java_web_start">Java Web Start</a> is a technology that allows easy deployment of Java based software through a web browser. The advantages of this framework are numerous but one nice thing is that it allows you far more freedom then the completely sandboxed Java applet. In this post I will detail how I converted my Hash Verifier application to run right from the browser.</p>
<p><strong>Java Network Launching Protocol (JNLP)</strong></p>
<p>The javax.jnlp libraries provide the functionality needed to launch the application from within a web browser. This is done through the use of a specially crafted XML file called a jnlp file. This file specifies the application information including the location of the executable jar and any class libraries associated with it. The nice thing about this is that it allows you to specify different class files spending on the platform it is being run on. This is exactly what I needed in order to get the correct SWT libraries loaded on the target platform.</p>
<p>As an example of what a jnlp file looks like here is the file I created for my Hash Verifier application:</p>
<blockquote><p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;<br />
&lt;jnlp spec=&#8221;1.0+&#8221; codebase=&#8221;http://www.tylerburton.ca/webstart&#8221; href=&#8221;hv.jnlp&#8221;&gt;<br />
&lt;information&gt;<br />
&lt;title&gt;Hash Verifier&lt;/title&gt;<br />
&lt;vendor&gt;tylerburton.ca&lt;/vendor&gt;<br />
&lt;homepage href=&#8221;http://tylerburton.ca&#8221; /&gt;<br />
&lt;description&gt;A graphical file digest generator&lt;/description&gt;<br />
&lt;description&gt;Hash Verifier&lt;/description&gt;<br />
&lt;/information&gt;</p>
<p>&lt;security&gt;<br />
&lt;all-permissions /&gt;<br />
&lt;/security&gt;</p>
<p>&lt;resources&gt;<br />
&lt;j2se version=&#8221;1.5+&#8221; /&gt;<br />
&lt;jar href=&#8221;HashVerifier.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Windows&#8221; arch=&#8221;x86&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-win32-windows-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Windows&#8221; arch=&#8221;x86_64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-win32-windows-x86_64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Windows&#8221; arch=&#8221;amd64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-win32-windows-x86_64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;ppc&#8221;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-ppc.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;ppc64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-ppc64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;x86_64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-x86_64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;amd64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-x86_64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;x86&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;i386&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Linux&#8221; arch=&#8221;i686&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-linux-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Mac&#8221; arch=&#8221;x86_64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-cocoa-mac-x86_64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Mac&#8221; arch=&#8221;amd64&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-cocoa-mac-x86_64.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Mac&#8221; arch=&#8221;x86&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-cocoa-mac-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Mac&#8221; arch=&#8221;i386&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-cocoa-mac-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Mac&#8221; arch=&#8221;i686&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-cocoa-mac-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;Mac&#8221;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-carbon-mac.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;SunOS&#8221; arch=&#8221;sparc&#8221;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-solaris-sparc.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;resources os=&#8221;SunOS&#8221; arch=&#8221;x86&#8243;&gt;<br />
&lt;jar href=&#8221;http://www.tylerburton.ca/swt/3.6.1/swt-gtk-solaris-x86.jar&#8221; /&gt;<br />
&lt;/resources&gt;</p>
<p>&lt;application-desc main-class=&#8221;ca.tylerburton.hashverifier.HashVerifierMain&#8221; /&gt;</p>
<p>&lt;/jnlp&gt;</p></blockquote>
<p>As you can see I have outlined all of the platform configurations that I am going to be compatible with. Java Web Start takes care of the rest for me automatically.</p>
<p><strong>Digital signatures</strong></p>
<p>The final step is to digitally sign the executable jar. This is required because when deploying an application that is not sandboxed, or one that requires access to low-level functions and libraries (as is the case in SWT), the end user needs to know that the code they are receiving came directly from the source. The easiest way to do this is to follow the <a href="http://eclipse.org/swt/jws/">instructions here</a>. Unfortunately unless you are willing to pay to have your certificate signed by a trusted certificate authority the end user will need to click OK through a big security warning before they can use your program. It&#8217;s a small issue to overcome but if <a href="http://www.minecraft.net/play.jsp" target="_blank">Minecraft</a> can do it without too much of a headache I&#8217;m sure you can too.</p>
<p><strong>Easy deployment</strong></p>
<p>It&#8217;s as simple as that. I didn&#8217;t have to re-write my code, heck I didn&#8217;t even have to adjust a single line and it all just works. To see the result on your platform <a href="http://www.tylerburton.ca/webstart/hv.jnlp">click here</a>. <strong></strong></p>
<p><strong>Note:</strong> unfortunately there is an issue with the Mac version of Java Web Start &amp; SWT that prevents it from working correctly. Until Apple fixes this, or OpenJDK takes over and does it, SWT applications cannot be started correctly on that platform through Web Start.</p>

<a href='http://www.tylerburton.ca/2010/10/hash-verifier-0-3-0-1-java-web-start/webstart1/' title='webstart1'><img width="150" height="150" src="http://www.tylerburton.ca/files/wordpress/2010/10/webstart1-150x150.png" class="attachment-thumbnail" alt="webstart1" title="webstart1" /></a>
<a href='http://www.tylerburton.ca/2010/10/hash-verifier-0-3-0-1-java-web-start/webstart2/' title='webstart2'><img width="150" height="150" src="http://www.tylerburton.ca/files/wordpress/2010/10/webstart2-150x150.png" class="attachment-thumbnail" alt="webstart2" title="webstart2" /></a>
<a href='http://www.tylerburton.ca/2010/10/hash-verifier-0-3-0-1-java-web-start/webstart3/' title='webstart3'><img width="150" height="150" src="http://www.tylerburton.ca/files/wordpress/2010/10/webstart3-150x150.png" class="attachment-thumbnail" alt="webstart3" title="webstart3" /></a>

<div class="shr-publisher-451"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2010/10/hash-verifier-0-3-0-1-java-web-start/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Updates to Java &amp; Mono</title>
		<link>http://www.tylerburton.ca/2010/10/updates-to-java-mono/</link>
		<comments>http://www.tylerburton.ca/2010/10/updates-to-java-mono/#comments</comments>
		<pubDate>Sat, 09 Oct 2010 18:19:00 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Programming Languages]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Java SE 7.0]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[Mono 2.28]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=439</guid>
		<description><![CDATA[Both Java and Mono (the open source implementation of C# and .NET) will be receiving pretty big updates this year. These represent two very popular virtual machine based coding platforms that offer portability and a slew of helpful standard libraries. Here are just a handful of the improvements each will see in the coming release. [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Both <a href="http://en.wikipedia.org/wiki/Java_%28programming_language%29">Java</a> and <a href="http://en.wikipedia.org/wiki/Mono_%28software%29">Mono</a> (the open source implementation of <a href="http://en.wikipedia.org/wiki/C_Sharp_%28programming_language%29">C#</a> and <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET</a>) will be receiving pretty big updates this year. These represent two very popular virtual machine based coding platforms that offer portability and a slew of helpful standard libraries. Here are just a handful of the improvements each will see in the coming release.</p>
<p><strong>Java SE 7.0</strong></p>
<p>While no tentative release date has been scheduled for Java 7 yet, the team has recently completed milestone 10 of 10. Sacrificing some features (which will be delayed until Java 8.0) Java 7 still has quite a few intriguing new additions.</p>
<ol>
<li><strong>G1 (new garbage 1st garbage collector)</strong>
<p>This new garbage collector improves upon the original generational one by introducing the concept of regions. You can think of regions has smart versions of the generational lists that should allow the collector to clean up large chunks of garbage with increased efficiency.</p>
</li>
<li><strong>Dynamic language support</strong>
<p>The <a href="http://en.wikipedia.org/wiki/Java_Virtual_Machine">JVM</a> will now support some internal changes which will allow dynamic languages (like Perl and Ruby) to leverage the speed and widespread nature of JVM for languages that aren&#8217;t strongly typed like Java. This in turn will will let dynamic languages have hooks into the standard Java libraries as well.</p>
</li>
<li><strong>NIO (New I/O) </strong>
<p>A new set of libraries for dealing with I/O. This will let Java do some interesting things like create symbolic links as well as giving general I/O operations a big performance boost.</p>
</li>
<li><strong>Native Java video libraries </strong>
<p>New standard video libraries will let the JVM playback and record video sources on any platform. No more relying on external libraries to do the job.</p>
</li>
<li><strong>Strings in switch statements </strong>
<p>I for one never really understood why you weren&#8217;t allowed to do this before. Obviously switch statements are highly optimized to act on numeric values but would it really be that hard for the compiler to change the string switch statement into an if statement for me? Now I don&#8217;t have to even think about it anymore.</p>
</li>
<li><strong>Automatic resource management </strong>
<p>Rather than having to worry about closing that I/O stream, Java will now take care of it for you. The new syntax is:do(BufferedInputStream bis = &#8230;) { //do some work} //it will automatically be closed here</p>
</li>
<li><strong>Others</strong>
<p>Other improvements include compressed 64-bit pointers to save memory, new parallel processing libraries to leverage multi-core CPUs and graphics acceleration improvements.</p>
</li>
</ol>
<p><strong>Mono 2.28</strong></p>
<p>The folks over at the Mono team just finished up a new release that contains quite a few interesting additions as well.</p>
<ol>
<li><strong>Full C#/ASP.NET 4.0 support </strong>
<p>This is nice to see because it means at the very least Mono and .NET are on equal footing when it comes to language syntax.</p>
</li>
<li><strong>New generational garbage collector </strong>
<p>Moving away from the older <a href="http://en.wikipedia.org/wiki/Boehm_garbage_collector">Boehm-Demers-Weiser</a> garbage collector to a new generation garbage collector (a la Java) should mean improved performance at the temporary expense of extra memory usage. This should let the runtime decide the best time to schedule a garbage collection action and only focus on the objects most likely to need collection.</p>
</li>
<li><strong>Dynamic language support </strong>
<p>Similar to Java, this version of Mono now also supports the System.Dynamic libraries. Again this will allow dynamic languages to leverage the portable nature of Mono as well as hooking into the various Mono runtime libraries.</p>
</li>
<li><strong>New parallel libraries and frameworks </strong>
<p>These new libraries should make it even easier to create applications that make use of parallel processing. Among the libraries is PLINQ, an optimized version of <a href="http://en.wikipedia.org/wiki/Language_Integrated_Query">LINQ</a> for multi-core systems.</p>
</li>
<li><strong>Overall performance improvements </strong>
<p>Mono now targets <a href="http://en.wikipedia.org/wiki/Low_Level_Virtual_Machine">LLVM</a> which should make it better as a server platform. In addition there have been a lot of code fixes and performance improvements throughout the project. Finally this version of Mono has also removed <a href="http://en.wikipedia.org/wiki/GLib">Glib</a> as a dependency which should make it lighter and more portable.</p>
</li>
</ol>
<div class="shr-publisher-439"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2010/10/updates-to-java-mono/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Introduction to SWT programming</title>
		<link>http://www.tylerburton.ca/2010/09/introduction-to-swt-programming/</link>
		<comments>http://www.tylerburton.ca/2010/09/introduction-to-swt-programming/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 01:11:22 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Created by Tyler Burton]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SWT]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=405</guid>
		<description><![CDATA[Back in this previous post I mentioned the possibility of putting up a sort of how-to guide on SWT programming. Well I&#8217;ve finally found some time to do so. I will try to make this as step-by-step as possible so that anyone reading this will completely understand what I&#8217;m doing. What you&#8217;ll need I&#8217;m making [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Back in <a href="http://www.tylerburton.ca/2010/08/make-java-guis-less-ugly-or-how-i-learned-to-love-swt/" target="_self">this</a> previous post I mentioned the possibility of putting up a sort of how-to guide on SWT programming. Well I&#8217;ve finally found some time to do so. I will try to make this as step-by-step as possible so that anyone reading this will completely understand what I&#8217;m doing.</p>
<p><strong>What you&#8217;ll need</strong></p>
<p>I&#8217;m making the following assumptions before starting:</p>
<ol>
<li>That you&#8217;ve already installed the <a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html">Java Development Kit</a> (<strong>not</strong> just the Java Runtime)</li>
<li>That you&#8217;ve installed <a href="http://eclipse.org/">Eclipse</a>. You can use an alternative but all of my examples will be based on Eclipse. I&#8217;m also going to assume that you are at least familiar enough with Eclipse to compile a Java program.</li>
<li>That you have some understanding of Java or at least some programming experience.</li>
<li>That you have the SWT library for your platform downloaded. You can find this on the download page <a href="http://download.eclipse.org/eclipse/downloads/drops/R-3.6-201006080911/index.php#SWT">here</a>.</li>
<li>That you&#8217;ve created a project in Eclipse (or your IDE) for this walk through.</li>
</ol>
<p><strong>Import SWT</strong></p>
<p>The first thing you want to do is import the SWT libraries that you have downloaded as an Eclipse project. Start by creating a new project specifically for SWT. For instance I named mine org.eclipse.swt (following the Java standard namespace naming conventions). Next import the SWT files into that project. To do this simply click File &gt; Import and then choose Archive File under the General folder.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-Import-.png"><img class="aligncenter size-medium wp-image-406" title="Screenshot-Import" src="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-Import--300x255.png" alt="" width="300" height="255" /></a></p>
<p>Then browse to the zip file you downloaded and choose the project to import this to (again in my example this project is org.eclipse.swt). When all is said and done you should have a project in your workspace for SWT similar to the one I&#8217;ve got here:</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/09/swt-project.png"><img class="aligncenter size-full wp-image-407" title="swt-project" src="http://www.tylerburton.ca/files/wordpress/2010/09/swt-project.png" alt="" width="252" height="186" /></a></p>
<p><strong>SWTify your project</strong></p>
<p>To finish adding the SWT libraries into your project we need to add them to your project&#8217;s class path. Right-click on your project and click properties. On the left hand side of the window you will see an item called Java Build Path. On that page there will be a number of tabs: Source, Projects, Libraries, etc. Click Projects and then click the Add button. Select the org.eclipse.swt project and click OK. You should see something like this indicating that the SWT libraries will be included in your project&#8217;s build path.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-Properties-for-My-SWT-Project-.png"><img class="aligncenter size-medium wp-image-408" title="Screenshot-Properties for My SWT Project" src="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-Properties-for-My-SWT-Project--300x189.png" alt="" width="300" height="189" /></a></p>
<p>We are now ready to begin programming!</p>
<p><strong>The default SWT program</strong></p>
<pre><span style="color: #800080;"><strong>import</strong></span> org.eclipse.swt.widgets.Display;
<span style="color: #800080;"><strong>import</strong></span> org.eclipse.swt.widgets.Shell;

<span style="color: #800080;"><strong>public class</strong></span> MySWTProject {

     <span style="color: #800080;"><strong>public static void</strong></span> main(String[] args) {

          Display display = <span style="color: #800080;"><strong>new</strong></span> Display();
          Shell shell = <span style="color: #800080;"><strong>new</strong></span> Shell(display);

          shell.open();

          <span style="color: #800080;"><strong>while</strong></span>(!shell.isDisposed()) {
               <span style="color: #800080;"><strong>if</strong></span>(!display.readAndDispatch()) {
                    display.sleep();
               }
          }

          display.dispose();
     }
}</pre>
<p>OK so what does it mean. In SWT all of the graphical things that you can do are tied to a Display object. A Display is essentially a link to the OS&#8217; underlying graphics output. What we are talking about is not a monitor &#8211; in fact a Display can contain multiple monitors &#8211; but rather a more abstracted concept of graphics. If this sounds confusing don&#8217;t worry, for the most part that&#8217;s all you&#8217;ll really need to know about the Display object.</p>
<p>A Shell should be a little easier to understand. It represents a window, the base application container. In fact if you run the above program you should see something like this:</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-SWT-Shell1.png"><img class="aligncenter size-medium wp-image-413" title="Screenshot-SWT-Shell" src="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-SWT-Shell1-300x261.png" alt="" width="300" height="261" /></a>A Shell can be manipulated in all of the ways that you think it would be. For instance you can give it a title by using the setText() method.</p>
<blockquote><p>shell.setText(<span style="color: #0000ff;">&#8220;Here is my window title&#8221;</span>);</p></blockquote>
<p>The open() method tells the Shell to start displaying itself. You can also do some interesting things like using the pack() method to size the Shell in order to make it just large enough to hold whatever you put into it.</p>
<p>The little while loop part first checks to make sure that our shell still exists and then executes any input that we may want our application to respond to (via the readAndDispatch() method). Finally we dispose of all resources we have requested from the OS by calling dispose() on the Display object. This is important because unlike regular Java programming we do not get automatic garbage collection in SWT. There is a silver lining however &#8211; calling dispose() on an object like Display will automatically call dispose() on any children that are registered with it. That is why we didn&#8217;t need to call dispose() on our Shell.</p>
<p><strong>OK I get it, now show me a button</strong></p>
<p>Interaction is very easy to add. For instance we can add a button to our Shell above by simply adding the following code after the line where we create our Shell.</p>
<pre>     Button button = <strong><span style="color: #800080;">new</span></strong> Button(shell, SWT.<span style="color: #0000ff;"><em>PUSH</em></span>);
     button.setText(<span style="color: #0000ff;">"Push Me"</span>);
     button.pack();</pre>
<p>Of course you will also need to import the Button library for this to work. In the constructor we pass in the shell (where we want to attach this button, similar to how we attached our shell to the Display object) and a flag called SWT.PUSH. SWT.PUSH tells the button to act as a push button. Next using setText() again we set the button label. Finally using the pack() method, as described above, we can resize the button to be <em>just </em>large enough. If you re-run the program now you will should see something like the following:</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-SWT-Button1.png"><img class="aligncenter size-full wp-image-415" title="Screenshot-SWT-Button" src="http://www.tylerburton.ca/files/wordpress/2010/09/Screenshot-SWT-Button1.png" alt="" width="88" height="69" /></a></p>
<p>Pretty simple stuff. We can even add an action listener that will respond when the button is pressed by using code like this:</p>
<pre>button.addSelectionListener(<span style="color: #800080;"><strong>new</strong></span> SelectionListener() {
    <span style="color: #800080;"><strong>p<span style="color: #800080;">ublic void</span></strong></span> widgetDefaultSelected(SelectionEvent e) {
          widgetSelected(e);
     }

     <span style="color: #800080;"><strong>public void</strong></span> widgetSelected(SelectionEvent e) {
          System.<span style="color: #0000ff;"><em>out</em></span>.println(<span style="color: #0000ff;">"The button was pressed!"</span>);
     }
});</pre>
<p>Again very simple. I hope that this very brief introduction will help people realize that SWT programming is very similar to regular AWT/Swing GUI creation (although each has their own unique weirdness). If you would like to download the sample code file that I used to create this you can do so <a href="http://www.tylerburton.ca/files/wordpress/2010/09/MySWTProject.java_.zip">here</a>. Please let me know if you have any questions about what I have said above, I&#8217;d be happy to help. On the other hand if you want a more in-depth look feel, free to hop over to my <a href="http://www.tylerburton.ca/software/">Hash Verifier</a> <a href="http://www.tylerburton.ca/2010/09/hash-verifier-0-3-0-0-a-k-a-the-swt-re-write/">post</a> and grab a copy of the source there. The Eclipse Foundation also has an excellent code snippet section <a href="http://www.eclipse.org/swt/widgets/">here</a> that will show you how to use each GUI widget.</p>
<p>Happy programming.</p>
<div class="shr-publisher-405"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2010/09/introduction-to-swt-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hash Verifier 0.3.0.0 (A.K.A. the SWT re-write)</title>
		<link>http://www.tylerburton.ca/2010/09/hash-verifier-0-3-0-0-a-k-a-the-swt-re-write/</link>
		<comments>http://www.tylerburton.ca/2010/09/hash-verifier-0-3-0-0-a-k-a-the-swt-re-write/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 02:27:29 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Created by Tyler Burton]]></category>
		<category><![CDATA[F/OSS]]></category>
		<category><![CDATA[hash verifier]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SWT]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=387</guid>
		<description><![CDATA[After reading up on how you can use SWT to give Java a more native look and feel I was interested in giving it a shot first hand. I decided to break out old faithful (Hash Verifier) and re-write it completely in Java/SWT. The end result was an application that has essentially equivalent functionality (see below for [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>After reading up on how you can use <a href="http://www.eclipse.org/swt/" target="_blank">SWT</a> to give <a href="http://www.java.com" target="_blank">Java</a> a more <a href="http://www.tylerburton.ca/2010/08/make-java-guis-less-ugly-or-how-i-learned-to-love-swt/" target="_blank">native look and feel</a> I was interested in giving it a shot first hand. I decided to break out old faithful (<a href="http://www.tylerburton.ca/software/" target="_blank">Hash Verifier</a>) and re-write it completely in Java/SWT. The end result was an application that has essentially equivalent functionality (see below for differences) but is completely cross-platform. No matter what operating system you end up running this on (Windows, Mac OSX, Linux) it should have a native look and feel. I will explain how I accomplished this literal &#8220;<strong>write once, run anywhere</strong>&#8221; code below.</p>
<p><strong>Easy deployment</strong></p>
<p>The download consists of three different programs. The first, and main, named <em>HashVerifier.jar</em> is not actually the Hash Verifier program, but rather a simple sequential application launching system that I wrote to make cross-platform deployment even easier. When you run <em>HashVerifier.jar</em>, either by double-clicking on it or by running it from the terminal with <em>java -jar HashVerifier.jar</em>, it opens up the included <em>rules</em> file and begins to execute the lines one after another. If there is a special platform specific file (such as <em>rules.mac</em>) it will run that instead. Let&#8217;s take a look at <em>rules:</em></p>
<p><code>java -jar AdaptiveSWT swt.jar<br />
java -XX:+AggressiveOpts -XX:+UseParallelGC -jar HashVerifierApp</code></p>
<p>As you can see each line is a separate command to be run.</p>
<p><strong>Getting that <em>right</em> look</strong></p>
<p>When <em>HashVerifier.jar</em> starts it reads each line and runs that as a shell command. The line <em>java -jar AdaptiveSWT swt.jar</em> starts the second included program. <em>AdaptiveSWT</em> uses Java&#8217;s built in cross-platform UI toolkit, <a href="http://en.wikipedia.org/wiki/Swing_(Java)" target="_blank">Swing</a>, and displays a small dialog while it downloads the platform&#8217;s native SWT library. This is necessary because otherwise I would need to create separate downloads for each platform, each with their unique native SWT library. By using <em>AdaptiveSWT</em> I can instead let it handle all of the dirty work for me. This is really the trick that lets me release exactly one version of the program that looks correct for everyone. The <em>AdaptiveSWT</em> program is even smart enough to know not to re-download the library if you already have it. That being said if you ever do have an issue where you need to re-download the library either delete the swt.jar file in the program directory or change the first line to <em>java -jar AdaptiveSWT -force swt.jar.</em> This forces the download to happen regardless of it you already have it or not.</p>
<p><strong>Hash Verifier</strong></p>
<p>The next line logically starts the actual Hash Verifier application (with a couple of extra performance enhancing flags passed along as well). This version should work almost identically as the previous with a few key differences:</p>
<ul>
<li>I have removed the <em>Export to Hash File</em> menu option as I simply just didn&#8217;t use it enough to warrant me spending the time to re-develop it.</li>
<li>I have removed the old <em>Help</em> menu option and replaced it with a visit website option.</li>
<li><a href="http://en.wikipedia.org/wiki/RIPEMD" target="_blank">RIPEMD-160</a> has been replaced with <a href="http://en.wikipedia.org/wiki/MD2_(cryptography)" target="_blank">MD2</a>, mostly because that is what the JVM supports &#8220;out-of-the-box&#8221;.</li>
</ul>
<p>That&#8217;s about it. Please let me know if you have any issues running it on your platform of choice.</p>
<p><strong>Requirements</strong></p>
<ul>
<li>OS: Windows, Mac OSX or Linux (Gtk+)</li>
<li>Internet connection</li>
<li>Java JRE (targeted at JavaSE-1.6 but might work on the previous version as well)</li>
</ul>
<p>As before the binary only package contains just the executables, whereas the all package contains the source code as well.</p>
<table border="1">
<tbody>
<tr>
<td></td>
<td><strong>Binary Only Package</strong></td>
<td><strong>All Package</strong></td>
</tr>
<tr>
<td><strong>File name:</strong></td>
<td>hash_verifier_0_3_0_0_binary.zip</td>
<td>hash_verifier_0_3_0_0_all.zip</td>
</tr>
<tr>
<td><strong>File hashes:</strong></td>
<td style="text-align: center;" colspan="2"><a href="http://www.tylerburton.ca/files/hashes/hash_verifier_0_3_0_0.hashes.txt" target="_blank">Download Here</a></td>
</tr>
<tr>
<td><strong>GPG signature:</strong></td>
<td><a href="http://www.tylerburton.ca/files/sigs/hash_verifier_0_3_0_0_binary.zip.sig">Download Here</a></td>
<td><a href="http://www.tylerburton.ca/files/sigs/hash_verifier_0_3_0_0_all.zip.sig">Download Here</a></td>
</tr>
<tr>
<td><strong>Screenshots:</strong></td>
<td><a href="http://www.tylerburton.ca/files/wordpress/2010/09/hvwindows.jpg"><img class="aligncenter size-thumbnail wp-image-389" title="HashVerifier on Windows" src="http://www.tylerburton.ca/files/wordpress/2010/09/hvwindows-150x150.jpg" alt="" width="150" height="150" /></a></td>
<td><a href="http://www.tylerburton.ca/files/wordpress/2010/09/hvlinux.png"><img class="aligncenter size-thumbnail wp-image-390" title="HashVerifier on Linux" src="http://www.tylerburton.ca/files/wordpress/2010/09/hvlinux-150x150.png" alt="" width="150" height="150" /></a></td>
</tr>
<tr>
<td><strong>License:</strong></td>
<td style="text-align: center;" colspan="2">(LGPL) <a href="http://www.gnu.org/licenses/lgpl.html" target="_blank">View Here</a></td>
</tr>
<tr>
<td><strong>Version:</strong></td>
<td style="text-align: center;" colspan="2">0.3.0.0</td>
</tr>
<tr>
<td><strong>File size:</strong></td>
<td>68.6KB</td>
<td>107.1KB</td>
</tr>
<tr>
<td><strong>File download:</strong></td>
<td><a href="http://www.tylerburton.ca/files/apps/hash_verifier_0_3_0_0_binary.zip">Download Here</a></td>
<td><a href="http://www.tylerburton.ca/files/apps/hash_verifier_0_3_0_0_all.zip">Download Here</a></td>
</tr>
</tbody>
</table>
<p><strong>NOTE:</strong> This software was tested on Windows Vista, Mac OS 10.6 and Linux Mint 9. While it may (and should) run on similar platforms I have not been able to test this. Please remember that this software is provided &#8220;as is&#8221; and without any sort of warranty. Use at <strong>your own risk</strong>.</p>
<div class="shr-publisher-387"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2010/09/hash-verifier-0-3-0-0-a-k-a-the-swt-re-write/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Make Java GUIs less ugly (&#8230;or how I learned to love SWT)</title>
		<link>http://www.tylerburton.ca/2010/08/make-java-guis-less-ugly-or-how-i-learned-to-love-swt/</link>
		<comments>http://www.tylerburton.ca/2010/08/make-java-guis-less-ugly-or-how-i-learned-to-love-swt/#comments</comments>
		<pubDate>Mon, 23 Aug 2010 02:47:06 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[Microsoft Windows]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[AWT]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Swing]]></category>
		<category><![CDATA[SWT]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=340</guid>
		<description><![CDATA[It&#8217;s no secret that while Java possess probably the most widely distributed, cross-platform, and common user interface libraries, graphical Java applications on the whole simply stand out for the wrong reasons. Whether the GUI comes in the form of the Abstract Window Toolkit (AWT) or Swing, each can be far from pretty and often do not [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It&#8217;s no secret that while Java possess probably the most widely distributed, cross-platform, and common user interface libraries, graphical Java applications on the whole simply stand out for the wrong reasons. Whether the GUI comes in the form of the <a href="http://en.wikipedia.org/wiki/Abstract_Window_Toolkit" target="_blank">Abstract Window Toolkit (AWT)</a> or <a href="http://en.wikipedia.org/wiki/Swing_%28Java%29" target="_blank">Swing</a>, each can be far from pretty and often do not mesh well with the platform they are being run on. For instance, running an AWT or Swing application can be an almost alien experience, no matter what operating system you are using, because neither uses the native control widgets. Even AWT, being a &#8216;thin&#8217; layer above the native controls, often looks completely bizarre. On Windows Vista AWT looks more like Windows 3.1 than anything else. Thankfully there is a nice alternative in the IBM created (and now Eclipse maintained) <a href="http://www.eclipse.org/swt/" target="_blank">SWT</a>.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/08/vis-example.png"><img class="aligncenter size-full wp-image-346" title="Windows Vista" src="http://www.tylerburton.ca/files/wordpress/2010/08/vis-example.png" alt="" width="225" height="225" /></a></p>
<p>The <a href="http://en.wikipedia.org/wiki/Standard_Widget_Toolkit" target="_blank">Standard Widget Toolkit</a>, or SWT, passes all GUI rendering responsibilities onto the host operating system. This allows for some interesting advantages like hardware rendered drawing for free (as an example). It also provides for a native look and feel because its <em>actually</em> using the real native widgets. So when run on Windows it looks like a regular Windows application and when run on Linux it looks like a Linux (GTK+) application. It also works on the Mac as well as a few other obscure platforms.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/08/lin-example.png"><img class="aligncenter size-full wp-image-345" title="Linux GTK+" src="http://www.tylerburton.ca/files/wordpress/2010/08/lin-example.png" alt="" width="212" height="224" /></a></p>
<p>Unfortunately because the application is now creating widgets outside of the JVM you are suddenly responsible for freeing the memory. There is <strong>no</strong> automatic garbage collection in the world of SWT. It&#8217;s not all bad however as freeing a parent object, like a window (referred to as a <em>shell</em> in SWT lingo), automatically frees all of its related child objects as well. Simply call the <em>.dispose()</em> method and 9 times out of 10 you are done.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/08/mac-example.png"><img class="aligncenter size-full wp-image-347" title="Mac OSX" src="http://www.tylerburton.ca/files/wordpress/2010/08/mac-example.png" alt="" width="232" height="237" /></a></p>
<p>Another other caveat is that you will still need to package the correct swt.jar file for your target platform. For instance Windows has its own version of swt.jar, as does Linux, and Mac, and so on and so forth. While this is rather annoying it does offer some interesting trade-offs. For instance you do not need to recompile your code just because you want to run it on a different platform; simply swap out the swt.jar file and watch as the <em>exact same code</em> generates completely different native GUIs. I even wrote a simple program that first checks what platform it is being run on and then downloads the correct swt.jar file before launching the GUI. This makes releasing the exact same package very simple.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/08/win-example.png"><img class="aligncenter size-full wp-image-351" title="Windows XP" src="http://www.tylerburton.ca/files/wordpress/2010/08/win-example.png" alt="" width="216" height="204" /></a></p>
<p>So how do you start using SWT? Head over to <a href="http://www.eclipse.org/swt/" target="_blank">http://www.eclipse.org/swt/</a> and download the newest stable version for your platform of choice. Depending on how you will be programing, all you have to then do is add the enclosed swt.jar to your class path. If you&#8217;re using <a href="http://en.wikipedia.org/wiki/Eclipse_(software)" target="_blank">Eclipse</a>, or a similar <a href="http://en.wikipedia.org/wiki/Swing_(Java)" target="_blank">IDE</a>, you can simply add the source as either part of you project, or as a separate referenced one, and take full advantage of the auto-complete as well. Perhaps I&#8217;ll get around to posting a more thorough how-to guide at some point in the future.</p>
<p><a href="http://www.tylerburton.ca/files/wordpress/2010/08/example_with_source.jpg"><img class="aligncenter size-medium wp-image-353" title="Example Window" src="http://www.tylerburton.ca/files/wordpress/2010/08/example_with_source-300x146.jpg" alt="" width="300" height="146" /></a></p>
<p>Like most things in software SWT is not perfect. There are still other challenges to overcome, such as creating each individual platforms&#8217; unique user experience to compliment their native GUI toolkits. That said if you&#8217;re looking for a way to leverage the widespread nature of Java, while still creating an application that <em>looks</em> like it belongs, SWT might just be what you&#8217;re looking for.</p>
<div class="shr-publisher-340"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2010/08/make-java-guis-less-ugly-or-how-i-learned-to-love-swt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Some quick tips to speed up Java and lower it&#8217;s memory usage</title>
		<link>http://www.tylerburton.ca/2010/08/some-quick-tips-to-speed-up-java-and-lower-its-memory-usage/</link>
		<comments>http://www.tylerburton.ca/2010/08/some-quick-tips-to-speed-up-java-and-lower-its-memory-usage/#comments</comments>
		<pubDate>Thu, 19 Aug 2010 02:32:19 +0000</pubDate>
		<dc:creator>Tyler Burton</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JVM]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://www.tylerburton.ca/?p=335</guid>
		<description><![CDATA[Java is an excellent programming language but too often the JVM seems to slow it down. Yes I know that there have been tremendous speed improvements in recent versions but the fact remains that it can still feel slow. It also tends to use an insane amount of memory to do just about anything (the [...]]]></description>
			<content:encoded><![CDATA[<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>Java is an excellent programming language but too often the JVM seems to slow it down. Yes I know that there have been tremendous speed improvements in recent versions but the fact remains that it can still <em>feel</em> slow. It also tends to use an insane amount of memory to do just about anything (the heap is cheap is the name of the game!). Well thankfully there are ways you can tighten the JVM&#8217;s belt and even fine tune its garbage collection process.</p>
<p><strong>Tune for Performance</strong></p>
<p>Tuning the JVM for performance can be as easy as launching your Java application with a few simple command line options tacked on. For instance you can simply specify that you want to use the server JVM (included in the JDK) instead of the client one. The server JVM is tuned to take slightly longer to start but to run faster in the long run. You can enable the server JVM by passing the <em>-server </em>option. You can also tell the JVM to be more aggressive with its optimizations by adding the option <em>-XX:+AggressiveOpts</em>. Or tell the JVM to cache commonly used strings by passing <em>-XX:+StringCache</em> as an option.</p>
<p><strong>Tune for Memory</strong></p>
<p>Tuning for memory can be just as easy. Here are some useful commands that you can throw at the JVM to lower memory usage. You can set the starting heap size by using the command line option <em>-Xms<strong>n</strong> </em>where <strong>n</strong> is the size. For instance -Xms2048k or -Xms2m (each 2MiB in size) are both valid. Alternatively to set the maximum heap size you can use <em>-Xmx<strong>n</strong> </em>where <strong>n</strong> is specified as above. This will force the JVM to attempt to keep the program within that heap size (by being far more aggressive with garbage collection). However this can be dangerous because your program will crash if it simply cannot fit within the maximum set size. Additionally you can also set the thread stack size by using <em>-Xss<strong>n</strong><span style="font-style: normal;">,</span> </em>again similar to above, but this might be even <em>more</em> dangerous than setting the overall program heap size. Finally you can enable a parallel garbage collector by using the command <em>-XX:+UseParallelGC</em>. This should <em>hopefully</em> speed up reference check searchings and the overall garbage collection rate.</p>
<p>Using the above methods you can really customize Java to run exactly as you wish on your machine. It might not be perfect, but with a little bit of work it can be a lot better than the defaults.</p>
<div class="shr-publisher-335"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><!-- End Shareaholic LikeButtonSetBottom Automatic -->]]></content:encoded>
			<wfw:commentRss>http://www.tylerburton.ca/2010/08/some-quick-tips-to-speed-up-java-and-lower-its-memory-usage/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

