Ben McCann

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

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


Injecting JUnit tests with Guice using a Rule


GuiceBerry is a pretty helpful library for injecting JUnit tests with Guice. However, it’s not super actively maintained and many of it’s methods and members are private making it difficult to change it’s behavior. Here’s a class, which essentially does what GuiceBerry does in one single class that you can edit yourself. import org.junit.rules.MethodRule; import Read More

Installing Mesos and Marathon on Ubuntu


Mesos is a distributed task framework. Marathon runs long-running tasks on Mesos. Here’s how you can install the latest versions. #### Dependencies: Java & Zookeeper sudo apt-get install -y default-jdk zookeeper-bin zookeeperd #### Install Mesos ubuntu_version=”12.04″ curl -fL “http://downloads.mesosphere.io/master/ubuntu/${ubuntu_version}/mesos_0.14.2_amd64.deb” –output mesos.deb sudo dpkg -i mesos.deb rm mesos.deb #### Install Marathon sudo mkdir -p /opt/marathon sudo Read More

Installing Oracle Java JDK on Ubuntu


Due to licensing restrictions, Ubuntu no longer comes with Oracle’s Java JDK. The first trick to installing on a headless server is being able to wget the file. I recommend downloading manually and then placing in on a host you control, your Dropbox directory, etc. You can install it by running: sudo mkdir -p /opt/java/64 Read More

Embedded Tomcat


Earlier in the year, I posted a quick writeup on how to run an embedded Jetty instance. Today, I’m posting basically the same code showing how to run an embedded Tomcat instance. The embedded Tomcat API is much nicer since it matches closely the web.xml syntax. However, the embedded Tomcat instance takes much longer to Read More

Using the Guice Struts 2 plugin


Guice 3.0 was released a few days ago!  One of the easiest ways to use it in your web server is to use Struts 2 with the Struts 2 plugin, which is available in the central Maven repository. This tutorial assumes familiarity with Guice and Struts 2. In order to use it the plugin, your Read More

Remote Java debugging in Eclipse


To debug a Java program being run on the command line from Eclipse you can start the Java program in remote debugging mode: java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y -jar myProgram.jar The program will wait for you to attach the Eclipse debugger to it. Open Eclipse and choose: Run > Debug Configurations… > Remote Java Application > New Read More

Google GXP Struts 2 Plugin


Google GXP is a replacement for JSP that provides compile-time type safety.  This article is a quick introduction on how to use GXP with Struts 2.   1. Download the jar.  It’s not in Maven yet because it’s still unreleased.   2. Install the jar in Maven or otherwise put it on your classpath.  You’ll Read More

Commons Math vs. ojAlgo


There are numerous math libraries for Java.   This is frustrating as a user because it’s hard to decide which to use.   Sometimes an algorithm is implemented in one library, but not another, which means you must marshal your data between proprietary formats.  I was working on solving systems of linear equations and there Read More

Embedded Jetty


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

Older Posts