<?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>When Brains Fly &#187; java</title>
	<atom:link href="http://www.whenbrainsfly.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.whenbrainsfly.com</link>
	<description>An Awesome Blog About Neuroscience, Computer Science, and Technology</description>
	<lastBuildDate>Mon, 28 Jun 2010 01:03:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Trying Out Citrus</title>
		<link>http://www.whenbrainsfly.com/2010/01/trying-out-citrus/</link>
		<comments>http://www.whenbrainsfly.com/2010/01/trying-out-citrus/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 02:40:43 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[citrus framework]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://www.whenbrainsfly.com/?p=207</guid>
		<description><![CDATA[As part of a new hobby/freelance project, I&#8217;ve been trying out the Citrus Framework, an integration test framework written in Java for SOA application. It&#8217;s quite neat and interesting. Right now, I&#8217;m using it mostly for testing sequences of HTTP GET and POST requests, and it works pretty nicely so far, although I did have [...]]]></description>
			<content:encoded><![CDATA[<p>As part of a new hobby/freelance project, I&#8217;ve been trying out the <a href="http://www.citrusframework.org/">Citrus Framework</a>, an integration test framework written in Java for SOA application. It&#8217;s quite neat and interesting. Right now, I&#8217;m using it mostly for testing sequences of HTTP GET and POST requests, and it works pretty nicely so far, although I did have to go into the source code and hack in handling for GET requests and variable URLs since those weren&#8217;t yet implemented. That was fun though and exposed me to some design patterns live in action in someone else&#8217;s code, which is pretty cool (I don&#8217;t see too much of this as a student writing my own code most of the time). Perhaps with more time and effort, I can clean up my changes and submit them to the framework developer(s) and actually be a part of open source software! That would be pretty exciting. </p>
<p>For the last week, working through this project, I&#8217;ve re-learned and learned quite a lot about HTTP requests, Ant, DTD/XSD, and XPath, and I feel much more comfortable dealing with those now than I did a week ago. It&#8217;s a good feeling to have learned and done something new that&#8217;s kind of on the cutting edge of things, and to have fun doing so too! Ah, I sound so corny. Anyway, I can&#8217;t wait to get more involved with the company that this project is for and delve into some code that has a lot of potential and fun-value. I&#8217;m just waiting on approval from the developers now, but so far things look good. Wish me luck! =)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whenbrainsfly.com/2010/01/trying-out-citrus/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Theme Updated and Miscellaneous Code</title>
		<link>http://www.whenbrainsfly.com/2009/08/theme-updated/</link>
		<comments>http://www.whenbrainsfly.com/2009/08/theme-updated/#comments</comments>
		<pubDate>Sat, 22 Aug 2009 05:34:33 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[admin]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://www.whenbrainsfly.com/?p=131</guid>
		<description><![CDATA[I wasn&#8217;t really liking the Brain Power theme anymore, so I decided to make my own using the handy-dandy WordPress Theme Generator and then tweaked the details to my liking. It looks better now, in my opinion.
Hopefully these changes plus the smackdown on spam will encourage me to blog some more. (Comments will still be [...]]]></description>
			<content:encoded><![CDATA[<p>I wasn&#8217;t really liking the Brain Power theme anymore, so I decided to make my own using the handy-dandy <a href="http://www.yvoschaap.com/wpthemegen/">WordPress Theme Generator</a> and then tweaked the details to my liking. It looks better now, in my opinion.</p>
<p>Hopefully these changes plus the smackdown on spam will encourage me to blog some more. (Comments will still be moderated until I am sure spam is under control.)</p>
<p>Now for some miscellaneous things:</p>
<p>In the meantime, for my reference, I like to keep two aliases for my bash shell:</p>
<pre>
alias ll='ls -l'
alias ls='ls -aG' # for the BSD ls
alias ls='ls -a --color=auto' # for the GNU ls
</pre>
<p>I also like to change the default color for directories (blue) to cyan when in BSD (cyan foreground not otherwise used) so that I can see it better.</p>
<pre>
export LSCOLORS="gxfxcxdxbxegedabagacad"
</pre>
<p>In GNU ls, there is a different method and cyan is used for symbolic links, so rather than have two different colors for directories, which I see far more often than symbolic links, let&#8217;s change the directory color to blue and symbolic link color to yellow:</p>
<p>&#8212;-I&#8217;ll finish this up soon&#8212;-</p>
<p>For compiling a Java program using Cygwin and including the jxl.jar library (typical bin, lib, src setup):</p>
<pre>
#!/bin/bash
javac -cp `cygpath -wp lib/jxl.jar:.` -d bin $(find src -name '*.java')
</pre>
<p>For running a Java program using Cygwin and including the jxl.jar library (two parameters passed):</p>
<pre>
#!/bin/bash
java -cp `cygpath -wp lib/jxl.jar:src/:.` main.class.Name $1 $2
</pre>
<p>For running the above Java program on a Mac without the Mac top menu bar and with a specified dock name:</p>
<pre>
#!/bin/bash
java -cp lib/jxl.jar:src/:. -Dapple.laf.useScreenMenuBar=true
-Xdock:name="Program Name" main.class.Name $1 $2
</pre>
<p>Note to self: &lt;pre&gt; tags do not have word wrap. Consider using a special scrollable text field or plugin for displaying code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whenbrainsfly.com/2009/08/theme-updated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>args4j is Awesome</title>
		<link>http://www.whenbrainsfly.com/2009/05/args4j-is-magic/</link>
		<comments>http://www.whenbrainsfly.com/2009/05/args4j-is-magic/#comments</comments>
		<pubDate>Thu, 28 May 2009 23:47:19 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[computer science]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[labwork]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://www.whenbrainsfly.com/2009/05/args4j-is-magic/</guid>
		<description><![CDATA[Today, I got frustrated writing a command-line input parser for my Java program for lab, so I looked for one on the web. Surely a task so common must have some good libraries that take care of it easily. I was not disappointed. 
Apache Commons has one, but it was kind of annoying. It left [...]]]></description>
			<content:encoded><![CDATA[<p>Today, I got frustrated writing a command-line input parser for my Java program for lab, so I looked for one on the web. Surely a task so common must have some good libraries that take care of it easily. I was not disappointed. </p>
<p>Apache Commons has <a href="http://commons.apache.org/cli/introduction.html">one</a>, but it was kind of annoying. It left a lot for me to do. I kept looking and found <a href="https://args4j.dev.java.net/">args4j</a> and thought it looked really neat. It makes good use of Java 5 annotations, which I have seen in action when writing a class JSF project. I tried it out, and after a little trouble learning what the annotation parameters meant (hint: see the <a href="https://args4j.dev.java.net/nonav/maven/apidocs/index.html">javadoc for @Option</a>), and with the help of Eclipse&#8217;s automatic getter generator, I got my command line parser up and running in minutes! Ah, the magic.</p>
<p>Here is the code, simple and sweet:</p>
<p>CommandLineValues.java:</p>
<pre>
import java.util.Random;

import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.Option;

public class CommandLineValues {

	/** Max value for the random seed (minimum is 0). */
	public static final int MAX_RANDOM_SEED = 1000;

	/** Valid options for the experiment type */
	public static enum ExptOption {
		DEGREES,
		FEATURES
	};

	@Argument(required = true, index = 0, usage = "type of experiment")
	private ExptOption exptOption;

	@Argument(required = true, index = 1, metaVar = "FILE",
			usage = "the config file for the experiment")
	private String configFileName;

	@Option(name = "-r", aliases = { "--resultsDir" }, metaVar = "DIR",
			usage = "directory to place the results file")
	private String resultsDir = "results/";

	@Option(name = "-s", aliases = { "--seed" }, metaVar = "VALUE",
			usage = "seed to use for the program's random number"
			 + generator")
	private int seed = (new Random()).nextInt(MAX_RANDOM_SEED + 1);

	// getters for all of the fields
}
</pre>
<p>The first and second arguments (<code>exptOption</code> and <code>configFileName</code>) are required; their order is set by the <code>index</code> parameter. The other two arguments are optional and have both a short single-dash flag (the <code>name</code> parameter) and a longer double-dash flag (the <code>aliases</code> parameter, which can contain any number of strings). The <code>metaVar</code> parameter describes the type of the argument in short, and the <code>usage</code> parameter describes the value of the argument.</p>
<p>Here is code showing how CommandLineValues.java is used.</p>
<p>Main.java:</p>
<pre>
public static void main(String[] args) {

	// parse the command line arguments and options
	CommandLineValues values = new CommandLineValues();
	CmdLineParser parser = new CmdLineParser(values);
	parser.setUsageWidth(80); // width of the error display area

	try {
		parser.parseArgument(args);
	} catch (CmdLineException e) {
		System.err.println(e.getMessage());
		System.err.println("java DotsMain [options...] arguments...");
		// print the list of available options
		parser.printUsage(System.err);
		System.err.println();
		System.exit(1);
	}
	// use the getters
}
</pre>
<p>Awesome! =)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.whenbrainsfly.com/2009/05/args4j-is-magic/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
