Templating in Java: What to use?
April 9, 2008
I’m looking into using a templating engine for formatting output from a Java component. From what I can tell, the top 3 templating engines for Java are Apache Velocity, Jxp, and FreeMarker.
Right away, Velocity stands out given the reputation of the Apache Foundation. Looking at Jxp, though, it’s appealing to be able to use standard Java code with the JSP-like syntax. If we can believe the FreeMarker site comparing it to Velocity, FreeMarker has better support for number and date manipulations (among other things), which could be particularly important for my uses.
I haven’t tried any of these engines out, yet. Rest assured, though, that I will try them and post my findings.
Profiling with Netbeans: Do You Have a Memory Leak?
February 23, 2008
This article on Netbeans.org discusses using the profiler bundled with the Netbeans IDE to detect memory leaks. By monitoring the surviving generations metric, one can supposedly catch a leak. I believe that this article ignores a certain situation.
New Hard Drive Woes for the Dell Dimension
February 11, 2008
As described in my earlier post, I managed to get my hand-me-down Dell Dimension 8400 desktop working after a little tinkering and a lot of reading. I installed Ubuntu 7.10 and was up and running for a good week.
But, alas, my poor computer was destined for yet another crippling problem. One evening as I read the news, the cpu usage maxed out, and the computer was unresponsive. I believe Firefox was the only application open. Regardless, it was under a very light load.
After turning the computer off, I waited a few seconds, and then pushed the power button. Instead of booting from my Ubuntu partition, Grub presented me with a command line. I tried manually booting from the hard drive with no luck.
ConcurrentHashMap to the Rescue
February 2, 2008
It was only a matter of time before I needed a Thread-safe Map. Looking at the synchronization wrappers for the Java Collections framework, I couldn’t help but be disappointed. The wrapper classes provide external synchronization on the entire Collection. That means that any read or update method is locking — one thing in at a time. What a performance bottleneck!
Read the rest of this entry »
Flashing Orange Light on Dell Dimension 8400
January 27, 2008
After reading all sorts of problem descriptions and solutions on various forums, I’ve finally fixed my hand-me-down Dell Dimension 8400 desktop box.
When I first got it, I couldn’t even get it to turn on. After pressing the power button, it gave a few beeps, started an orange blinking with the power light, and refused to do anything else. Some people with the same problem had to replace the motherboard, the power supply, or the memory. Some still don’t have a working computer.
As for me, I unplugged all of the devices from the power supply, removed the memory sticks, and then put it all back together. Something along the way did the trick — I suspect it was removing and re-inserting the memory, but I’m not certain.
Now my box is up and running with Ubuntu 7.10!Leave a comment if you’ve had a similar problem with your Dell — I know there are a lot of you guys out there. Maybe you can post some other solutions and ideas here to help out…
Update: According to the Dell manual, there are 4 lights on the back of the tower labeled A, B, C, and D. If the A and B lights are orange, but the C and D lights are green, it could mean that the memory isn’t recognized and that you need to take out the memory sticks and put them back in again. This sounds like it could have been my problem.
Hashtable or HashMap?
January 17, 2008
Working on some Java code, I recently found myself in need of a hash-type data structure. The project I’m working on frequently uses a home-grown hash table implementation, but I wanted to transition to the more recently developed Java Collection classes. Since J2SE 1.5.0, the data structures in the Collections framework have been updated to use Generics, which are cleaner and provide safety against casting errors.
Without giving it much thought, I started using the java.util.Hashtable implementation. But soon I stumbled upon the java.util.HashMap class. Not knowing the differences between the two, I read through the API documentation to compare both implementations.
As it turns out, there are some important differences. First, Hashtable is synchronized, meaning that it can be used concurrently by multiple processes/threads without the need for synchronization outside of the object. HashMap, on the other hand, is not synchronized. To use a HashMap object in a concurrent programming environment, you’d need synchronization external to the object.
Secondly, Hashtable does not allow null keys or values, whereas HashMap does. This was important for my project because the existing code required the ability to use null as a value. To change that behavior would be outside the scope of my task.
Finally, HashMap allows values to be safely removed during iteration, but Hashtable does not.
After comparing the two Collections classes, I chose to use HashMap mainly due to the fact that it allows null values. Since the existing source code requires null values in some cases, this ability was a necessity. The fact that HashMap does not provide synchronization is insignificant for my project — there is no concurrent access to these data structures. Although concurrency is planned in the future, there already exists a need for synchronization at a higher level.
Regardless of the differences between Hashtable and HashMap, I feel much better about using either one than the in-house hash table implementation developed circa jdk 1.0. At least I won’t have to worry about casting.
Update: After reading a little more about the Collections framework, I’ve discovered that there is a way to get synchronized versions of the unsynchronized classes. Java provides a set of synchronization wrappers capable of producing thread-safe versions of any Collection. Pretty cool!
Kayak Travel Search Engine
December 13, 2007
A colleague recently told me about Kayak. It’s a tool for searching flights, hotels, rental cars, and cruises, but I’ve only used it to lookup up and compare flights. Kayak’s pretty useful for finding the right flight; you can choose the number of stops, which airlines you’d like to consider, and what online travel agencies you’d like to search.
Some of its more interesting features are charts that show the historical prices for flights between the cities you picked. There’s a chart for the past 90 days and a chart for every day of the month you’ve chosen to travel.
On top of its handy features, Kayak has an interface that’s both useful, easy on the eyes, and easy to navigate. Plus, the site uses advertisements sparingly. Most travel sites I’ve seen are teaming with ads, slow to load, and visually confusing. Nice job, Kayak.
Simple Leftover Thanksgiving Turkey Recipe
November 24, 2007
This comes courtesy of my soon-to-be mother-in-law:
1/2 to 1 lb. cooked turkey
2 cups gravy
1 lb. campanelle pasta
1/2 to 1 cup grated parmesan cheese
Chop turkey into small pieces. Boil the pasta, drain, return to pot. Heat gravy in separate container. Add turkey and gravy to pasta. Salt and pepper to taste. Spoon the mixture into a large casserole dish and top with parmesan cheese. Bake at 375 degrees for 20-30 minutes.
This simple recipe is a great way to use the leftover Thanksgiving turkey’s flavor in a new setting, and it’s quick and easy to prepare. Give it a try and tell me what you think!
Yahoo: Linux Not Supported
November 23, 2007
I’m running Fedora 7 on my old laptop. Take a look at Yahoo’s message to me after signing out of Flickr and clicking the “Return to Yahoo” link:

Windows, Mac, and — what, no Linux? You’ve got to be kidding! Firefox is only supported for Windows and Mac? Why on earth would my operating system matter, as long as it’s the same browser?
Well, Yahoo, I recommend that you stop censoring content based on my operating system. It’s bad enough that you’re doing it based on browser. And this from the developers of the Yahoo User Interface (YUI) that supposedly has wide browser support! I suppose I should at least thank them for providing the link to continue “living on the edge” and not completely banning me from the site.
Create and Upload Your Own CSS Stylesheet
November 18, 2007
I stumbled across the css Zen Garden today. This site lets web designers upload their own external css stylesheets to be applied to the site with the goal of attracting graphic artists to the wonder that is css web design. I found this one and this one particularly appealing out of the handful of designs I’ve viewed.
I’m wondering if I should make a stylesheet for css Zen Garden. I have been learning quite a lot lately about css and web development in general, but I don’t think my focus has been on the design aspect as much as the technical.
Also, I think I’d like to design this blog’s stylesheet. I’d like to put my personal touch on it, and I think it would be fun! Before I do that, though, I’ll need to get my own server space to host the blog, and I don’t have the time at the moment to look for a hosting provider.