Alvin Alexander | Java, Scala, Unix, Perl, Mac OS X

Here is a link to Steve McConnell's Classic Mistakes Enumerated, from his book titled "Rapid Development". It is a great listing of 36 common problems that plague software development projects.

Linux grep FAQ: How can I use the grep command to search for multiple patterns with one command?

A little while ago I needed to search for all files in a CVS repository that contain multiple character patterns. That is, I wanted to be able to grep multiple patterns in multiple files. In my case the patterns I was looking for were the strings "prevayl" and "jtable".

One thing to note about jEdit if you're going to use it on Microsoft Windows: If you like to open files from the Windows Explorer by right-clicking on a file, and then selecting an option like "Open with jEdit", you need to use the Windows installer.

I don't write much in the way of business application code any more, but if I did, I would generate Java code like crazy.

Think about it, whenever you write database-driven applications, one common denominator is that every database driven project has the database design completed before you start coding. And then, once you start coding, I'll bet 80% of the code is related to what I call CRUD ("create, read, update, delete") functionality.

And you know what -- you can generate this Java database code, either statically, or more powerfully, dynamically.

I can never find a list of states for an HTML select/option list (aka, combobox, drop-down list) when I need one, so I’m putting two versions here. The first select/option list shows a list of states, but only shows the abbreviations of the states:

By default jEdit stops at the beginning and end of each word when using the "next word" (CTRL + Right Arrow) and "previous word" (CTRL + Left Arrow) actions. Personally, I don't like this; I'd much rather it stop only at the beginning of each word. Fortunately the authors have made it easy to change this, if not easy to find.

To change this behavior in jEdit, you just need to remap the keystrokes to alternative actions. Just follow these steps:

Java servlet redirect FAQ: Can you provide an example of how to perform a Java servlet redirect?

Some time ago I wrote about forwarding from a servlet to a JSP. Depending on the circumstance I might rather redirect from a servlet to a JSP. When I need to to do a redirect instead of a forward I use this code:

Here's a quick note for those of us that like to create prototypes during a requirements process using HTML. Whenever you want to create a button that is supposed to simulate the action of moving to another screen, you can use code similar to the following code snippet to simulate this behavior:

Java Hibernate debug faq: How can I see the SQL that is actually being run/executed when I'm using Hibernate?

To debug Hibernate output, just configure this parameter in your file:


This Hibernate configuration parameter will cause Hibernate to show the actual SQL that is being generated/used when your queries are run. Of course it can be a little verbose, but hopefully it will also give you all the SQL you need to troubleshoot your problem.

This Java class still needs some work, but it's my first attempt at creating a Java Swing component that simulates a hyperlink. Basically, if you use this label (a JHyperlinkLabel to be precise) instead of a JLabel you should see hyperlink behavior on your Swing labels (JLabel).

JTable popup menu introduction

Here's a copy of a class file I created to demonstrate how to put a popup menu (JPopupMenu) on a JTable in a Java application. Actually, the intent of this particular class was to see if I could get the popup menu to work on the header cell of a JTable, but that ended up being a no-brainer.

Wow, it's been a long time since I've done anything out here. Busy, busy, busy. Here's a link to a tutorial I've written about creating a splash screen for Java applications.


This Java Monte Carlo simulation tutorial, and the corresponding Java program, was inspired by the story and subsequent movie "Minority Report", as well as my recent interest in Monte Carlo simulations.

A co-worker, Chris Smith, created a very elegant Perl program to parse a Microsoft Excel XLS file for me some time ago. I recently modified that program to convert what was essentially a "glossary" in an Access database.

I first saved the Access database table as an Excel file. Then I used the following Perl program to extract the contents of the second and third columns from that file, and write them out to another file. The output file was in a Wiki (technically TWiki) format.

Here's a link to a tool named JSmooth that lets you create Windows executable files from standard Java JAR files. It looks like this can make the installation process on the Windows platform much more friendly.


Ant web build script FAQ: Can you share an example Ant build script for a web application?

Sure, here's a sample Ant build script for a Java web application. I've included other example Ant scripts for Java Swing/JFC/GUI applications on this website, but this one demonstrates how to use Ant to build a web app instead.

Ant Swing build script FAQ: Can you share an example of an Ant build script for Java Swing applications?

Here is another sample Ant build script for a Java application. Again, I hope it can help you "Learn Java by Example", or in this case, "Learn Ant by Example".

Ant Java build scripts: Can you share an example of an Ant build script for a standalone Java application?

This is a sample Ant build script for a Java application I wrote. It is a GUI/Swing application named "AlwaysOnTop". I include it here because I'm a big believer in learning by example, and maybe this Ant script can help you create an Ant script for your own applications.