Archive for the ‘Java’ Category

Random Java Stuff

Thursday, June 28th, 2007

Java Genetic Algorithms Package (JGAP) is (surprise) a genetic algorithm package for Java. JGAP 3.2 was recently released. Coolest feature: you can use JGAP to evolve a Robocode robot (more about Robocode).

After reading this post by Bill Pugh to OpenJDK’s quality-discuss mailing list, I immediately gave FindBugs a try. The Eclipse plugin for FindBugs is highly recommended. Getting FindBugs going is Maven is a bit more… interesting. I think you want the findbugs-maven-plugin, although there’s also a maven-findbugs-plugin. It seems findbugs-maven-plugin includes support for FindBugs 1.2.0, but I wasn’t able to consistently convince it to use that instead of 1.0.0. Good luck.

I promptly unleashed FindBugs on Apache ActiveMQ and found some minor issues and some more serious issues. Maximum respect to Rob Davies for fixing the latter collection.

Update: I unleashed FindBugs on JRuby. See JRUBY-1173.

Java Thread vs Executor

Tuesday, June 19th, 2007

Quote of the day from Java Concurrency in Practice: “The primary abstraction for task execution in the Java class libraries is not Thread, but Executor.”

My weekend on JRuby on Rails

Sunday, May 20th, 2007

I played with JRuby and Rails this weekend.

I’m trying to create a standalone JAR that contains Jetty and a Rails application so that you can fire up a server using java -jar railsapp.jar, like you can do with Hudson. This involves taking the existing work that allows you to bundle your Rails application into a WAR (which can be deployed to a server) a bit further. I haven’t quite figured out how to configure Jetty to do this yet. It seems Jetty’s WebAppContext wants to be configured with a directory that contains the web application. I’ve asked on the Jetty mailing list for some tips.

I choose redMine at random for my experiments. I couldn’t get redMine to create its database with Apache Derby, due to some issue with DATEs and TIMESTAMPs. Getting this to work would be great, since then you have a server-in-JAR that is completely standalone.

However, everything worked fine with MySQL over JDBC. Running redMine under JRuby using WEBrick worked great (after a minor workaround for JRUBY-964), but I had an issue with it failing to start when deployed as a WAR, due to some problem with the IConv.open method. I’ll investigate this a bit more.

Along the way, I submitted two JRuby bugs (JRUBY-954, JRUBY-964), commented on JRUBY-925 and produced a simple test case for JRUBY-956, which is a bug the Mingle folks ran into. I also did some debugging of JRUBY-822.

Along the way, this Rails Cheat Sheet came in handy, since I haven’t looked at Rails since 2005.

UISpec4J and why I dislike Swing

Sunday, May 20th, 2007

UISpec4J is library for testing Swing-based Java applications, built on top of JUnit. I’m not Swing’s biggest fan, but this looks pretty useful.

Now, on to why I don’t like Swing. Let’s take a look at a Open File dialog box in a a Swing application (NetBeans 6.0M9):

springfile.png

vs an SWT application (Eclipse 3.2.2):

swtfile.png

Because SWT uses the native control, it works exactly like my other Windows applications. I can type something like %HOME%\foo\bar into the File name field and it will open the corresponding directory. Swing doesn’t understand %HOME%. Sure, it could be fixed to understand it, but that’s not the only issue. Another thing that pains me is that interaction with Swing using the keyboard doesn’t feel like other Windows applications. Here I’m thinking about using TAB to skip between elements, typing the first few letters of an item to jump to it or navigating with the arrow keys.

If NetBeans didn’t have such great support for Ruby and Rails, I wouldn’t have any major Swing applications on my machine. (By the way, how about a NetBeans download that only includes the core and the Ruby plugin? That would rock.)

Maven: The Definitive Guide

Thursday, May 17th, 2007

Sonatype are working on a free book about Maven, Maven: The Definitive Guide.

Java Dynamic Management Kit open sourced as OpenDMK

Thursday, May 17th, 2007

Sun has open sourced the Java Dynamic Management Kit as OpenDMK. If you haven’t experienced the beauty that is JConsole (which uses JMX to retrieve all kinds of useful bits from your JVM), be sure to fire it up sometime. Now imagine JConsole on steroids, built right into your application. This can really take management of a large Java system (spread across many physical machines) to a new level. Disclaimer: I haven’t used this library yet, so I can only hope that it’s as great as they say it is.

Links of the day

Wednesday, May 16th, 2007

MultithreadedTC: A framework for testing concurrent Java applications

Friday, May 11th, 2007

MultithreadedTC is a framework that makes it easier to test concurrent abstractions (as opposed to JUnit, which doesn’t play well with threads). It was mentioned in the talk by Pugh, Goetz (of Java Concurrency in Practice fame) and Click (of lock-free hash table fame) on Testing Concurrent Software at JavaOne 2007.

IKVM.NET vs the world

Sunday, May 6th, 2007

I spent a few hours during the last week downloading and building various Java codebases and testing them with IKVM.NET.

So far, I’ve tried:

Most of the projects used Apache Ant to build. A few used Maven. Some projects had an Ant rule to download dependencies (nice touch). Other projects included their dependencies inside the source repository. Overall, building the projects using Ant inside Eclipse was a breeze.

I think all the projects used JUnit as is, with the exception of Derby, which has a rather complicated test setup (probably for good reasons).

I managed to reduce two failing test cases to Classpath bugs, namely bug #31814 (already fixed) and bug #31819. Jeroen Frijters also found and fixed various bugs.

I also played with the idea of setting up a Hudson instance to do all this automatically in the future. Take a look. I’ll contact the Classpath folks next week to here if they want to provide a permanent home for this setup.

Google TechTalk: Guice

Sunday, May 6th, 2007

I watched the Google TechTalk Java on Guice: Dependency Injection, the Java Way today. Very interesting stuff. Definitely worth watching before you dive into the rest of the Guice documentation.