<?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>A Noted Path by Theodore Nguyen-Cao &#187; java</title>
	<atom:link href="http://www.theodorenguyen-cao.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.theodorenguyen-cao.com</link>
	<description>Personal blog of Theodore Nguyen-Cao</description>
	<lastBuildDate>Wed, 21 Jul 2010 15:40:42 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Google App Engine adds Java support (Review)</title>
		<link>http://www.theodorenguyen-cao.com/2009/04/08/google-app-engine-adds-java-support-review/</link>
		<comments>http://www.theodorenguyen-cao.com/2009/04/08/google-app-engine-adds-java-support-review/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 20:30:32 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[appengine]]></category>
		<category><![CDATA[review]]></category>

		<guid isPermaLink="false">http://www.theodorenguyen-cao.com/?p=293</guid>
		<description><![CDATA[Last night Google announced Java support on Google App Engine. After a bit of toying around, here are my findings. The Eclipse plugin is pretty slick. Deploying and build is simple. The dev server that you spin up locally looks to be jetty under the hood. Objects intended for storage are JDO annotated and after [...]]]></description>
			<content:encoded><![CDATA[<p>Last night Google <a href="http://googleappengine.blogspot.com/2009/04/seriously-this-time-new-language-on-app.html">announced</a> Java support on Google App Engine.</p>
<p>After a bit of toying around, here are my findings.</p>
<p>The Eclipse plugin is pretty slick. Deploying and build is simple.</p>
<p>The dev server that you spin up locally looks to be jetty under the hood.</p>
<p>Objects intended for storage are JDO annotated and after compiling, you run the .class files through the DataNucleus Enhancer which adds additional metadata so Google can map it to BigTable.  The Eclipse plugin automatically performs this step for you after compiling. The examples provide a bunch of ant macros to help facilitate building/deploying.</p>
<p>One issue that I had was that the project was building with Java 1.6 and I would get an error after compiling:</p>
<pre class="console">Caused by: java.lang.UnsupportedClassVersionError: Bad version number in .class file</pre>
<p></p>
<p>Even though they say they support Java 1.5 and 1.6, I guess this doesnâ€™t work on the Java 1.6 for the Mac.  Switching the build to 1.5 allows the DataNucleus Enhancer to run successfully. </p>
<p>Even though they are using JPA, some features have not yet been implemented or supported ( see <a href="http://code.google.com/appengine/docs/java/datastore/usingjpa.html#Unsupported_Features_of_JPA">http://code.google.com/appengine/docs/java/datastore/usingjpa.html#Unsupported_Features_of_JPA</a>)</p>
<p>Overall, I like what I see so far and think this would be great for quick prototypes of web apps/services.</p>
<p>Going through the tutorial, my awesome <a href="http://notedpath.appspot.com/guestbook.jsp">Guestbook</a> application has been created and deployed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2009/04/08/google-app-engine-adds-java-support-review/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Eclipse Ganymede + Subclipse = Unable to load default SVN client???</title>
		<link>http://www.theodorenguyen-cao.com/2008/09/26/eclipse-ganymede-subclipse-unable-to-load-default-svn-client/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/09/26/eclipse-ganymede-subclipse-unable-to-load-default-svn-client/#comments</comments>
		<pubDate>Fri, 26 Sep 2008 14:46:21 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.theodorenguyen-cao.com/2008/09/26/eclipse-ganymede-subclipse-unable-to-load-default-svn-client/</guid>
		<description><![CDATA[I like Shiny New Things. So when I heard Eclipse Ganymede SR1 was available, I proceeded to replace the Stream Stable Build I was currently running. This, of course, ended up causing me problems. After installing Subclipse and attempting to pull up any SVN history, I get an error dialog box that states: &#8220;Unable to [...]]]></description>
			<content:encoded><![CDATA[<p>I like <a href="http://onstartups.com/home/tabid/3339/bid/6739/Entrepreneurs-and-Hey-There-s-A-Shiny-New-Thing.aspx">Shiny New Things</a>. So when I heard <a href="http://www.eclipse.org/downloads/packages/release/ganymede/sr1-rc2/">Eclipse Ganymede SR1</a> was available, I proceeded to replace the <a href="http://www.theodorenguyen-cao.com/2008/02/27/eclipse-leopard-crash/">Stream Stable Build</a> I was currently running.</p>
<p>This, of course, ended up causing me problems.  After installing Subclipse and attempting to pull up any SVN history, I get an error dialog box that states:<br />
&#8220;Unable to load default SVN client&#8221;</p>
<p>Confused, I <a href="http://en.wikipedia.org/wiki/RTFM">RTFM</a> and saw that &#8220;Subclipse 1.4.x requires Subversion 1.5.0 version of JavaHL/SVNKit&#8221;</p>
<p>Seeing the SVN I was running was in fact not 1.5,</p>
<pre class="console">
  theo@notedpath~ $ svn --version
svn, version 1.4.4 (r25188)
   compiled Nov 25 2007, 08:20:33</pre>
<p>I went <a href="http://www.collab.net/downloads/apple/download.html">here</a>, downloaded and installed Subversion 1.5, restarted Eclipse and things are looking good now.</p>
<p>Stupid shiny new things.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/09/26/eclipse-ganymede-subclipse-unable-to-load-default-svn-client/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Breaking Java Habits: Ruby increment/decrement operators</title>
		<link>http://www.theodorenguyen-cao.com/2008/03/15/breaking-java-habits-ruby-incrementdecrement-operators/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/03/15/breaking-java-habits-ruby-incrementdecrement-operators/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 23:03:07 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/03/15/breaking-java-habits-ruby-incrementdecrement-operators/</guid>
		<description><![CDATA[My background in C++ and Java has instilled in me some programming habits that don&#8217;t play nice in Ruby. When I want to increment or decrement a number, my fingers instinctively go to &#8216;++&#8217; and &#8216;&#8211;’&#8217;. Unfortunately, this syntax is not supported by Ruby. As a language design choice, Ruby opted to not support this [...]]]></description>
			<content:encoded><![CDATA[<p>My background in C++ and Java has instilled in me some programming habits that don&#8217;t play nice in Ruby.  When I want to increment or decrement a number, my fingers instinctively go to &#8216;++&#8217; and &#8216;&#8211;’&#8217;.</p>
<p>Unfortunately, this syntax is not supported by Ruby.  As a language design choice, Ruby opted to not support this syntactic sugar to increment/decrement a variable.</p>
<p>I will have to break my habit and start going with:</p>
<pre name="code" class="ruby">
// increment x
x+=1
// decrement x
x-=1</pre>
<p>Another thing to note is that the prefix increment/decrement operators like &#8216;&#8211;x&#8217; or &#8216;++x&#8217; do nothing. The signs are interpreted as unary operators.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/03/15/breaking-java-habits-ruby-incrementdecrement-operators/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java WTF: Reflection API and Annotations</title>
		<link>http://www.theodorenguyen-cao.com/2008/03/07/java-wtf-reflection-api-and-annotations/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/03/07/java-wtf-reflection-api-and-annotations/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 05:04:20 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/03/07/java-wtf-reflection-api-and-annotations/</guid>
		<description><![CDATA[I got some exposure to custom Java 5 Annotations today and came across a noobie mistake. Here&#8217;s my annotation: public @interface Annotated { } Pretty simple, right? Here&#8217;s a test class that uses the annotation: import java.lang.annotation.Annotation; @Annotated public class Main { public static void main(String[] args) throws Exception { for(Annotation ann: Main.class.getAnnotations()) { System.out.println(ann); [...]]]></description>
			<content:encoded><![CDATA[<p>I got some exposure to custom Java 5 <a href="http://java.sun.com/j2se/1.5.0/docs/guide/language/annotations.html" target="_blank">Annotations</a> today and came across a <a href="http://www.urbandictionary.com/define.php?term=noobie" target="_blank">noobie</a> mistake.</p>
<p>Here&#8217;s my annotation:</p>
<pre name="code" class="java">
public @interface Annotated {
}</pre>
<p>Pretty simple, right?</p>
<p>Here&#8217;s a test class that uses the annotation:</p>
<pre name="code" class="java">
import java.lang.annotation.Annotation;

@Annotated
public class Main {
    public static void main(String[] args) throws Exception {
        for(Annotation ann: Main.class.getAnnotations()) {
            System.out.println(ann);
        }
    }
}</pre>
<p>What does this print?<br />
&#8230;<br />
Nothing!</p>
<p>Well, WTF?</p>
<p>Turns out Annotations are not run-time accessible unless you declaratively specific it via <code>@Retention</code>.  The updated annotation looks like this:</p>
<pre name="code" class="java">
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

@Retention(RetentionPolicy.RUNTIME)
public @interface Annotated {

}</pre>
<p>By default, the Retention is specified with RetentionPolicy.CLASS which, per the javadocs, &#8220;Annotations are to be recorded in the class file by the compiler but need not be retained by the VM at run time.&#8221;</p>
<p>RetentionPolicy.RUNTIME allows the annotation &#8220;to be recorded in the class file by the compiler and retained by the VM at run time, so they may be read reflectively.&#8221;</p>
<p>File this one under, <a href="http://en.wikipedia.org/wiki/RTFM" target="_blank">RTFM</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/03/07/java-wtf-reflection-api-and-annotations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java WTF: Calendar vs Date</title>
		<link>http://www.theodorenguyen-cao.com/2008/03/06/java-wtf-calendar-vs-date/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/03/06/java-wtf-calendar-vs-date/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 04:33:54 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/03/06/java-wtf-calendar-vs-date/</guid>
		<description><![CDATA[I&#8217;ve been doing some date math at work and I came across something I thought was wack. Check this out: Calendar cal1 = Calendar.getInstance(); Thread.sleep(500); Calendar cal2 = Calendar.getInstance(); Thread.sleep(500); Date now = new Date(); System.out.println(cal1.before(cal2)); System.out.println(cal1.before(now)); What do you think this snippet prints (It compiles, I promise!)? Looking at the code, it shows that [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some date math at work and I came across something I thought was wack.</p>
<p>Check this out:</p>
<pre name="code" class="java">
Calendar cal1 = Calendar.getInstance();
Thread.sleep(500);
Calendar cal2 = Calendar.getInstance();
Thread.sleep(500);
Date now = new Date();

System.out.println(cal1.before(cal2));
System.out.println(cal1.before(now));</pre>
<p>What do you think this snippet prints (It compiles, I promise!)?</p>
<p>Looking at the code, it shows that we are getting three snapshots in time, waiting half a second between snapshots, and assigning those values to <code>cal1</code>,<code>cal2</code>, and <code>now</code>, respectively. I put in the Thread.sleep() to illustrate the point more clearly. The first print statement compares the first and second snapshots in time, returning true if the first is before the second.  The second print statement returns true if the first is before the third snapshot.</p>
<p>Logically, we would expect both print statements to prints true.  However, this outputs:</p>
<pre name="code" class="java">
true
false</pre>
<p>But, how could the first snapshot be before the second snapshot but not the third?</p>
<p>Putting up the <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html" target="_blank">javadocs</a>, gives us our answer.  The Calendar <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#before(java.lang.Object)" target="_blank">before</a> and <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Calendar.html#after(java.lang.Object)" target="_blank">after</a> methods always returns false if you don&#8217;t pass it a Calendar object.  Why? I have no idea. Why not just have the method signature take a Calendar object?  I mean, I guess this allows you to extend Calendar to be able to call after/before on whatever kind of classes you want to support&#8230;but does it really make sense to compare a Calendar to a Monkey class?  This is what I call a Java WTF.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/03/06/java-wtf-calendar-vs-date/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Eclipse + Leopard = Crash?</title>
		<link>http://www.theodorenguyen-cao.com/2008/02/27/eclipse-leopard-crash/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/02/27/eclipse-leopard-crash/#comments</comments>
		<pubDate>Wed, 27 Feb 2008 06:49:53 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[geekery]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/02/27/eclipse-leopard-crash/</guid>
		<description><![CDATA[I recently upgraded to Leopard on my work MacBook Pro. In Eclipse, one of the first things I ran into was anytime I tried to do Open Resource (Shift + APPLE + R) to open a file resource, Eclipse would crash with a nasty exception. Exception Type: EXC_BAD_ACCESS (SIGBUS) After doing a bit of googling, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently upgraded to Leopard on my work MacBook Pro.  In Eclipse, one of the first things I ran into was anytime I tried to do Open Resource (Shift + APPLE + R) to open a file resource, Eclipse would crash with a nasty exception.</p>
<p><strong>Exception Type:  EXC_BAD_ACCESS (SIGBUS)</strong></p>
<p>After doing a bit of googling, this seems to be a bug in SWT for Leopard (see <a href="http://https://bugs.eclipse.org/bugs/show_bug.cgi?id=207827" target="_blank">here</a>).  I upgraded my Eclipse to the 3.4 Stream Stable Build found at <a href="http://download.eclipse.org/eclipse/downloads/">http://download.eclipse.org/eclipse/downloads/</a> and my problems have seem to gone away.</p>
<p>It&#8217;s got a pretty cool new splash screen too <img src='http://www.theodorenguyen-cao.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
<center><br />
<a href="http://blog.notedpath.com/wp-content/uploads/2008/02/eclipse-34.jpg" title="eclipse-3.4 splash screen"><img src="http://blog.notedpath.com/wp-content/uploads/2008/02/eclipse-34.jpg" alt="eclipse-3.4 splash screen" /></a></center></p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/02/27/eclipse-leopard-crash/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Using JMeter for load testing</title>
		<link>http://www.theodorenguyen-cao.com/2008/02/10/using-jmeter-for-load-testing/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/02/10/using-jmeter-for-load-testing/#comments</comments>
		<pubDate>Sun, 10 Feb 2008 19:00:37 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/02/10/using-jmeter-for-load-testing/</guid>
		<description><![CDATA[I came across JMeter a while back but never got a chance to try it out. From the JMeter website: Apache JMeter is a 100% pure Java desktop application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions. This [...]]]></description>
			<content:encoded><![CDATA[<p>I came across <a href="http://jakarta.apache.org/jmeter/" target="_blank">JMeter</a> a while back but never got a chance to try it out. From the JMeter website:</p>
<blockquote><p><em>  Apache JMeter  is a 100% pure Java desktop application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.</em></p></blockquote>
<p>This weekend I was able to test load on my <a href="https://manage.slicehost.com/customers/new?referrer=90780688" target="_blank">256 slice</a> which this blog is running on.  Here&#8217;s what I did:</p>
<ol>
<li><strong>Download the binary</strong><br />
You can get the binary <a href="http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi" target="_blank">here</a>.</li>
<li> <strong>Unzip the tarball/zip file</strong><br />
I extracted it file to <code>/Users/theo/tools/jakarta-jmeter-2.3.1</code></li>
<li><strong>Start up JMeter</strong><br />
Go to the <code>bin</code> directory.  Run <code>jmeter.sh</code> (<code>jmeter.bat</code> if using Windows) from the command line.</li>
<li> <strong>Create a Test Plan</strong><br />
Just give a name and any description you want for your test plan.<a href="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_create_test_plan.png"><img src="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_create_test_plan.png" alt="jmeter_create_test_plan" height="273" width="449" /></a></li>
<li> <strong>Create a Thread Group</strong><br />
A thread group allows you to specify the amount of load you want to simulate.  Select your test plan from the left Tree view, right-click, and select Add -&gt; Thread Group.</p>
<p>Configurable fields include:</p>
<ul>
<li>Number of threads &#8211; the number of connections or users you want to simulate</li>
<li>Ramp up period &#8211; the amount of time in seconds to take to reach the number of threads specified.  If you  choose 0, all of the threads will be created at the start of the test.</li>
<li>Loop count &#8211; you can specify to loop indefinitely or provide a number of times to run through the test.</li>
</ul>
<p><a href="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_create_thread_group.png"><img src="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_create_thread_group.png" alt="jmeter_create_thread_group" height="273" width="449" /></a></li>
<li><strong>Add a Sampler</strong><br />
A sampler is a type of request you want to make.  In this example, I used an HTTP request to test load to a web server.  It&#8217;s good to note JMeter supports multiple types of samplers including web services, JMS, and JDBC.  Add a sampler by selecting the Thread Group you just created, right-click, select Add -&gt; Sampler -&gt; HTTP Request.</p>
<p>Configurable properties include:</p>
<ul>
<li>Server Name &#8211; what the ip or url is to the server the request it to</li>
<li>Port &#8211; the port the  server is listening to</li>
<li>Protocol &#8211; the protocol (http, https, etc)</li>
<li>Method &#8211; HTTP method (POST,GET, PUT, DELETE, etc)</li>
<li>Path &#8211; the URL path to request</li>
</ul>
<p><a href="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_create_http_request.png"><img src="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_create_http_request.png" alt="jmeter_create_http_request" height="271" width="450" /></a></li>
<li><strong>Add a Listener<br />
</strong>A listener allows you to collect data points and display them in some fashion like a graph or a table.  I used the Graph Results listener by selecting the Thread Group, right-click, select Add -&gt; Listener -&gt; Graph Results.</li>
<li><strong>Run the test!</strong><br />
Now we are ready to run the test. From the file menu bar, select Run -&gt;Start.  You will be prompted to save your test plan.  You can save it or just hit &#8220;No&#8221;.  You should see data points begin to be plotted on the Graph Result or whatever listener you selected.</p>
<p><a href="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_graph_results.png"><img src="http://blog.notedpath.com/wp-content/uploads/2008/02/jmeter_graph_results.png" alt="jmeter_graph_results" height="249" width="450" /></a><br />
I monitored the usage from my slice as well and this is what top showed me:</p>
<p><a href="http://blog.notedpath.com/wp-content/uploads/2008/02/slice_top_load_test.png" title="slice_top_load_test"><img src="http://blog.notedpath.com/wp-content/uploads/2008/02/slice_top_load_test.png" alt="slice_top_load_test" height="276" width="450" /></a></p>
<p>You can see the 5 threads we specified in the Thread Group taking up 5 apache processes.</li>
<li><strong>Interpret the results</strong><br />
Tests are worthless without interpreting the results.  So, what the heck does this graph tell me?  Pretty good documentation can be found <a href="http://jakarta.apache.org/jmeter/usermanual/component_reference.html#Graph_Results" target="_blank">here</a>. Basically, given the load scenario we have setup, my slice can handle ~643 requests/minute or ~11 requests/second.  I am not sure what kind of numbers I should be getting but these seem pretty good to me. One last thing to note is that JMeter is not a web browser so these metrics don&#8217;t include rendering time or execution of any JavaScript.</li>
</ol>
<p>Overall, JMeter seems to be a great open source tool to test different kinds of load on servers.  I look forward to trying it out at work.  One last thing I came across is JMeter integration with your Ant build process.  Check that out <a href="http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php" target="_blank">here</a>. I would like to hear about other people&#8217;s experiences with JMeter, too.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/02/10/using-jmeter-for-load-testing/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Installing Java SDK/Tomcat to Ubuntu Feisty (Part 2)</title>
		<link>http://www.theodorenguyen-cao.com/2008/01/21/installing-java-sdktomcat-to-ubuntu-feisty-part-2/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/01/21/installing-java-sdktomcat-to-ubuntu-feisty-part-2/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 05:24:44 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/01/21/installing-java-sdktomcat-to-ubuntu-feisty-part-2/</guid>
		<description><![CDATA[In the previous post, I described how to get your Java SDK installed on your machine. In this piece, I&#8217;ll lay out how to get your tomcat instance up and running. Let&#8217;s setup our JAVA_HOME. While you can set this setting in many places, I decide to stick it in bash.bashrc. My Java installation from [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://blog.notedpath.com/2008/01/20/installing-java-sdk-to-ubuntu-feisty/">previous post</a>, I described how to get your Java SDK installed on your machine.  In this piece, I&#8217;ll lay out how to get your tomcat instance up and running.</p>
<p>Let&#8217;s setup our JAVA_HOME.  While you can set this setting in many places, I decide to stick it in bash.bashrc.</p>
<p>My Java installation from <code>apt-get</code> put Java under <code>/usr/lib/jvm/java-6-sun</code>.</p>
<pre class="console">sudo vi /etc/bash.bashrc</pre>
<p>Enter in:</p>
<pre class="console">
# set JAVA_HOME environment variable
JAVA_HOME=/usr/lib/jvm/java-6-sun</pre>
<p>Save and quit vi. Log out and log back into your console and you should be able to do</p>
<pre class="console">
 &gt;&gt;echo $JAVA_HOME
/usr/lib/jvm/java-6-sun</pre>
<p>I went through the initial attempt of installing tomcat from apt-get.  This resulted in a successfully download of all the files, but I wasn&#8217;t able to get tomcat to start up.  Not only that, it installed tomcat and created symbolic links everywhere and there were permission issues galore.  Thanks to the beauty of <a href="http://www.slicehost.com">slicehost</a>, I just rebuilt my machine from my previous snapshot (luckily I made a snapshot after the previous post).</p>
<p>So, I decided to just download and install tomcat manually. I decided on apache-tomcat-5.5.25.</p>
<p>To get started, download the tarball and extract it somewhere.</p>
<pre class="console">
wget http://apache.cs.utah.edu/tomcat/tomcat-5/v5.5.25/bin/apache-tomcat-5.5.25.tar.gz
tar xzvf apache-tomcat-5.5.25.tar.gz
cp -R apache-tomcat-5.5.5 &lt;PATH_TO_TOMCAT_INSTALL&gt;</pre>
<p>You will need to go to the bin directory and set some file permissions so you can execute some of the files.</p>
<pre class="console">
cd &lt;PATH_TO_TOMCAT_INSTALL&gt;/bin
sudo chmod a+x *.sh</pre>
<p>It&#8217;s a probably good time to see if things are looking good. So try,</p>
<pre class="console">
 &gt;&gt; ./version.sh
Using CATALINA_BASE:   /usr/share/tomcat
Using CATALINA_HOME:   /usr/share/tomcat
Using CATALINA_TMPDIR: /usr/share/tomcat/temp
Using JRE_HOME:       /usr/lib/jvm/java-6-sun
Server version: Apache Tomcat/5.5.25
Server built:   Aug 24 2007 05:33:50
Server number:  5.5.25.0
OS Name:        Linux
OS Version:     2.6.16.29-xen
Architecture:   amd64
JVM Version:    1.6.0-b105
JVM Vendor:     Sun Microsystems Inc.</pre>
<p>Sexy.  Let&#8217;s go ahead and try to startup tomcat.</p>
<pre class="console">
./startup.sh</pre>
<p>By default, tomcat should be running on port 8080.  (If you tried to install from <code>apt-get</code>, it&#8217;s setup on port 8180)<br />
<center><br />
<img src="http://blog.notedpath.com/wp-content/uploads/2008/01/tomcat-default-page.png" alt="tomcat default page" height="250" width="500" /><br />
</center><br />
<strong>Setting up the tomcat manager</strong></p>
<pre class="console">
sudo vi conf/tomcat-users.xml</pre>
<p>We need to setup a manager role to see the tomcat status page:</p>
<pre name="code" class="xml">
&lt;tomcat-users&gt;
  ...
  &lt;role rolename="manager"&gt;
  ...
  &lt;user username="admin" password="mysecretpassword" roles="tomcat,manager"&gt;
&lt;/tomcat-users&gt;</pre>
<p>Restart tomcat and confirm you can log into the Tomcat status page and we&#8217;re done!</p>
<p>TODOS:</p>
<ul>
<li>I need to setup the system to run tomcat on startup</li>
<li>I need to write an init.d script</li>
<li>I need to get tomcat to proxy through apache via mod_jk</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/01/21/installing-java-sdktomcat-to-ubuntu-feisty-part-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Installing Java SDK/Tomcat to Ubuntu Feisty (Part 1)</title>
		<link>http://www.theodorenguyen-cao.com/2008/01/20/installing-java-sdk-to-ubuntu-feisty/</link>
		<comments>http://www.theodorenguyen-cao.com/2008/01/20/installing-java-sdk-to-ubuntu-feisty/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 18:48:26 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2008/01/20/installing-java-sdk-to-ubuntu-feisty/</guid>
		<description><![CDATA[When I first got my slice, I had it setup with java and tomcat. Apparently, I updated or rebuilt my slice and forgot to install those two again. Too bad I didn&#8217;t take good notes because I totally forgot how to do it. So this time, I&#8217;m going to document it via this post. I [...]]]></description>
			<content:encoded><![CDATA[<p>When I first got my slice, I had it setup with java and tomcat. Apparently, I updated or rebuilt my slice and forgot to install those two again.  Too bad I didn&#8217;t take good notes because I totally forgot how to do it.</p>
<p>So this time, I&#8217;m going to document it via this post.</p>
<p>I am currently running Ubuntu Feisty (v. 7.04). You can find out what version you&#8217;re running by running the following command:</p>
<pre class="console">cat /etc/issue</pre>
<p>The usual <code>apt-get</code> command allows me to install sun-j2re1.4.  That&#8217;s not very helpful if I want to compile java code off of my slice or set it up to be a continuous build server.  I remember that I had to add a specific repository in order to be able to install the Java SDK via apt-get.  After some digging around, I came up with the following:</p>
<pre class="console">sudo vi /etc/apt/sources.list</pre>
<p>Paste the following into the file:</p>
<pre class="console">
deb http://archive.ubuntu.com/ubuntu feisty universe multiverse
deb-src http://archive.ubuntu.com/ubuntu feisty universe multiverse</pre>
<p>The Ubuntu <a href="https://help.ubuntu.com/community/Repositories/CommandLine#what">docs</a> recommend enabling the universe/multiverse security/updates repositories to prevent version mismatches during installs or upgrades but I didn&#8217;t run into any issues proceding without them.</p>
<p>Save and exit out of vi.</p>
<p>Next, run</p>
<pre class="console">sudo apt-get update</pre>
<p>apt-get should be pulling down an updated list of installable packages. So if you type</p>
<pre class="console">sudo apt-get install sun-j</pre>
<p>and then hit TAB, you should get a list of installable sun packages.</p>
<p>I decided to install Java 6.0 SDK.</p>
<pre class="console">sudo apt-get install sun-java6-sdk</pre>
<p>It will begin to download and install the SDK.  You will have to accept a license. Just hit TAB to get select &#8220;OK&#8221; and hit enter.</p>
<p>Once it completes, you should be able to confirm the JDK was installed successfully.</p>
<pre class="console">
  &gt;&gt; javac -version
javac 1.6.0</pre>
<p>The next post will lay out steps to install Apache Tomcat.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2008/01/20/installing-java-sdk-to-ubuntu-feisty/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Java Puzzlers: Google TechTalk</title>
		<link>http://www.theodorenguyen-cao.com/2007/08/26/java-puzzlers-google-talk/</link>
		<comments>http://www.theodorenguyen-cao.com/2007/08/26/java-puzzlers-google-talk/#comments</comments>
		<pubDate>Sun, 26 Aug 2007 15:31:56 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2007/08/26/java-puzzlers-google-talk/</guid>
		<description><![CDATA[Here&#8217;s an interesting talk at Google by Josh Bloch, author of Java Puzzlers and special guest Bill Pugh. I definitely learned a few things about Java from it.]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s an interesting talk at Google by Josh Bloch, author of <a href="http://javapuzzlers.com">Java Puzzlers</a> and special guest Bill Pugh.</p>
<p><center><br />
<embed style="width:400px; height:326px;" id="VideoPlayback" type="application/x-shockwave-flash" src="http://video.google.com/googleplayer.swf?docId=9214177555401838409&#038;hl=en" flashvars=""> </embed><br />
</center></p>
<p>I definitely learned a few things about Java from it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2007/08/26/java-puzzlers-google-talk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hello, World &#8211; Java</title>
		<link>http://www.theodorenguyen-cao.com/2007/08/19/hello-world-java/</link>
		<comments>http://www.theodorenguyen-cao.com/2007/08/19/hello-world-java/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 18:13:38 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2007/08/19/hello-world-java/</guid>
		<description><![CDATA[Trying out the WP-Syntax WordPress plugin: public class Hello { public static void main(String[] args) { System.out.println("Hello World!"); } } Check it out at: http://wordpress.org/extend/plugins/wp-syntax/]]></description>
			<content:encoded><![CDATA[<p>Trying out the WP-Syntax WordPress plugin:</p>
<pre lang="java">
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}</pre>
<p>Check it out at: <a href="http://wordpress.org/extend/plugins/wp-syntax/">http://wordpress.org/extend/plugins/wp-syntax/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2007/08/19/hello-world-java/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Apache, Tomcat, Rails</title>
		<link>http://www.theodorenguyen-cao.com/2007/08/19/apache-tomcat-rails/</link>
		<comments>http://www.theodorenguyen-cao.com/2007/08/19/apache-tomcat-rails/#comments</comments>
		<pubDate>Sun, 19 Aug 2007 17:09:54 +0000</pubDate>
		<dc:creator>Theo</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.notedpath.com/2007/08/19/apache-tomcat-rails/</guid>
		<description><![CDATA[It was easier than I thought it would be to install Java and Tomcat. With a few apt-get commands, I had both Java and Tomcat up and running. The next step was to serve Tomcat through Apache. This was done by using the AJP Connector. Tomcat is running with AJP connector port 8009 and I [...]]]></description>
			<content:encoded><![CDATA[<p>It was easier than I thought it would be to install Java and Tomcat.  With a few <em>apt-get</em> commands, I had both Java and Tomcat up and running.  The next step was to serve Tomcat through Apache.  This was done by using the AJP Connector.  Tomcat is running with AJP connector port 8009 and I can serve up JSPs and servlet content through Apache who is listening on port 80. Pretty slick <img src='http://www.theodorenguyen-cao.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It was even easier to get a Rails app up and running on WEBrick on default port 3000.</p>
<p>Next steps will be to serve Rails content through Apache.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodorenguyen-cao.com/2007/08/19/apache-tomcat-rails/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
