I’m doing some work on a side project within Yahoo!. Among other things, the code needs to be able to make HTTP requests. Using java.net.URL isn’t very tantalizing, mostly because it’s a total pain in the ass (try getting the returned content when an HTTP 400 error code is sent back to you, try building up a query string).
One of the only other Java-based HTTP libraries is available as part of Jakarta: HttpClient. So you download the JAR, dump it into your project, compile and run. BOOM! It blows up in your face:
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
Okay, you need to have the commons logging package in order to be able to use HttpClient. I really hate the whole idea behind the commons logging package, but I need HttpClient. So I (grudgingly) pull it down and add it to my project libraries. Run my project again. BOOM! It blows up in your face:
java.lang.NoClassDefFoundError: org/apache/commons/codec/DecoderException
What the?!? What the hell is commons codec? You have to be kidding me. I have to pull down ANOTHER dependency? I was hoping to keep dependencies to a minimum with this project. Now I have 3 brand new dependencies just because I wanted to make some stupid HTTP requests.
I guess the moral of the story is, if you want to keep dependencies to a minimum you might as well handroll the functionality you want.
As a side note, those 3 new dependencies are 350KB in size. So much for making something lean that could possibly be used on an embedded device.