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

I'm going to live with some monks for the rest of this week and early next week, so things will be quiet here.

This may be a little too touchy-feely for some people, but as I prepare for this trip, the one thing I was struck with this morning is how bad we have been to the Earth since North America was first colonized. Looking at things from the perspective of the Earth, things were pretty good back in the days when the Indians roamed this continent. Since then, we've built all of these cities, "conquered" all of this land, and then polluted the air, land, and water.

Wow, I just learned about the Linux locate command the other day. I'm going to have to quit using find so much. The locate command is very quick, assuming it can find what it's looking for in it's cache.

Here's a quick locate example. Assume that you have apache installed on your system, but you can't remember where it is. Just type locate apachectl to find the apachectl command, and you'll see locate return some output, very quickly, like this:

Java Mail (JavaMail) IMAP FAQ: Can you show me how to get a list of all the email addresses in an IMAP mailbox using the Java Mail API (JavaMail API)?

Sure. Here's the source code for a Java mail (JavaMail) program that extracts all of the "from" fields out of a specified mailbox. This works for both POP3 and IMAP mailboxes.

Before going to the code, note the cool use of a TreeSet (java.util.TreeSet) in this example. Based on our offline discussion, you mentioned that you really want is this:

One other Unix command while I'm in the neighborhood. Somewhat along the lines of what I was doing on Monday -- looking at the size of Apache log files -- I wanted to generate a sorted list of log files for May and June only. Here's how to solve that problem by grouping Unix commands:

(may;jun) | sort +4n

In this example, I'm grouping the commands 'may' and 'jun' together using the parentheses, and piping their combined output into the sort command. With the sort command, I'm sorting numerically by the 5th column.

It looked like one of our servers was getting hit pretty hard a while ago, and since we have about 100 sites on that server, I needed a way to find the largest log file. How to solve this? The Linux find command!

First, cd to your apache log file directory. Next, here's the command that showed me the access log files on our system, sorted in ascending order by size:

find . -name "access*" -mtime -1 -exec ls -ld {} \; | sort +4n

Ahh, brings tears of joy to my eye just looking at it. :)

 

What are the possible properties you can get from System.getProperty() you might ask ... or in my case, really need to know(!). This URL from a Sun tutorial provides the necessary relief, er, help.

 

I started the Google AdWords campaign last night. I'm using AdWords to supplement some of the searches where the www.devdaily.com site does not appear in the first page of search results. One example is when google users search for "unix example", the "www" site does not show up well for some reason. Therefore, I'm spending a little money to buy some exposure. Stay tuned for results...

Back to thinking about JLint ... there seems to be several implementations of this on the web. The one I downloaded is from artho.com. One thing that was not clear from the instructions was how to run this program. I *assumed* that I would point it at a source file, but I really needed to point it at a *class* file. Once I figured this out, running it became a simple matter of moving to the directory that contained the class files and typing this

jlint Main.class

Here are two links to Java/OOP and Unix training material I'm getting online as fast as possible:

By the time this is all published in the next two weeks, it should be nearly 1,000 pages of online training material. Woo-hoo!

 

I saw this guy's page a long time ago, and don't want to forget about him again. The site is joelonsoftware. He seems to have some good stories on software dev.

The most amusing part of the last month or so in the tech industry has been the effort of SCO to sue IBM over their use/implementation of Linux. Here is a position paper by Eric Raymond regarding the lawsuit, on behalf of the Open Source Initiative. It should be noted that Raymond was a regular speaker at the SCO Forum for several years back in the 90s.

Here are a few notes from "my other life". Amazing what happens when I've actually gotten a little sleep. It's been this way since forever.

Here's the material from a seminar I've done several times on "Working Backwards with JUnit". The idea for this seminar came about from an article of the same name by several authors in the Extreme Programming blue book. I can't remember their names right now, but all of the credit goes to them for the idea, and I need to acknowledge them properly.  

Java JTextField question: How do I right-align the text in a JTextField?

Short answer:

myTextField.setHorizontalAlignment(SwingConstants.TRAILING);

Long answer: I need to look at this some more to understand the difference between the alignment constants in SwingConstant and the alignment constants in JTextField.

Holy Microsoft Passport security flaws! Where do you want to trust your money today?

For some reason I woke this morning thinking of Object Mothers and Immutable Objects. No rhyme, no reason. However, I am beginning to think that everything I need -- programming-wise -- is at the c2.com wiki site.

(From a recent email.) Help, I have a 13-column JTable, inside of a jscroll pane, inside of a borderlayout, inside a JDialog. Ideally, I would like the dialog to initially open up to the correct width needed to display the 13 columns without horizontal scrolling.

Setting the preferred width of each column (only) does not work very well. Setting the minWidth gets the columns to open up to the correct width, but then the last 7 or so columns fall off the right hand side of the dialog.

Java FAQ: Can you share some source code for a “Java wget” program, i.e., a Java program that works like the Unix wget or curl commands?

Here's the source for a program I've named JGet, which acts similar to the wget or curl programs. I didn't have wget installed when I needed it (and my client wouldn't let me install it), so I wrote this Java wget replacement program.

I have used GRASP in one context in this blog, but the GRASP I'm interested in today refers to Craig Larman's General Responsibility and Assignment Patterns. I saw those first referenced in Larman's book titled "Applying UML and Patterns". Larman's home page is one big page, but what the heck, he's a good author.