Quantcast

Ben McCann

Co-founder at Connectifier.
ex-Googler. CMU alum.

Ben McCann on LinkedIn Ben McCann on AngelList Ben McCann on Twitter

Java

Embedded Jetty

01/19/2011

One of the coolest things about Jetty is the ability to run it in embedded mode.  This means that you can write a Java app with a main method that will launch a Jetty server.  This has some really nice benefits.  For example, it makes it really easy to deploy a server to EC2 because Read More

Easy Java Bean toString() using BeanUtils

07/10/2008

I often want to have a String description of my beans for debugging or logging purposes, but hate having to manually concatenate the fields in my class to create a toString() method. This code snippet using Apache Commons is very helpful for just such occasions. Thanks to Paul Wilton who suggested this updated code snippet in Read More

HTML Parsing using the Firefox DLLs

03/21/2008

One of my first posts was a comparison of HTML parsers. Today I found a particularly challenging document to parse. None of the parsers I had compared earlier were able to handle the malformed HTML in this table where the td elements were prematurely ended. The behavior of Neko and HtmlCleaner made the most sense Read More

Suppressing Compile Warnings with Java Annotations

02/23/2008

If you’ve used Java 1.5 Generics much then you’re probably familiar with the following compile warning: “Type safety: The expression of type List needs unchecked conversion to conform to List<String>” or similar. It turns out there’s a rather simple solution with annotations to ignore this problem: @SuppressWarnings(“unchecked”) A couple other possible uses of the annotation Read More

Running Ant within Eclipse

01/30/2008

I tried to run an Ant target within Eclipse today and got a fun error: BUILD FAILED java.lang.NoClassDefFoundError: com/sun/javadoc/Type This happened because Ant could not find tools.jar, which contains classes to used to run javac and javadoc. The solution: Open up Window->Preferences->Java->Installed JREs Set your default JRE to a JDK/SDK Open up the one you Read More