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

Using hypertext and hyperlinks in Java Swing applications makes them look more like web applications, and that's often a very good thing. Here's a quick example of how to add a Java HyperlinkListener to a component in Java. In this case the component I'm going to use is a JEditorPane.

Me: "I'd like the #8 (a taco, chili relleno, beans, and mexican salad) with no beans please." (Thinking to myself that this is just too much food, and since I'm trying to cut down my proportions I decide to skip the beans.)

Waiter: "Ok."

Five minutes go by ... the waiter comes back with a taco, a chili relleno, a mexican salad ... and rice. Apparently saying "no beans" means "rice".

How often are you stuck in a dualistic world like this, unable to see another option? How often do you not communicate well?

 

Java current directory FAQ: Can you share an example of how to determine the current directory in Java?

You can determine the current directory your application is started in using Java's System.getProperty() method and the user.dir property, like this:

Wow, this was a tough LaTeX problem, and it would really help if I knew a lot more about LaTeX.

My goal for a LaTeX PDF that I created recently was to get the header of my pages to look something like this:

Section Name (Chapter Name)

where "Section Name" and "Chapter Name" are left-aligned in the header of the page, and would be dynamically replaced by the actual values of the current section and chapter names, respetively.

Summary: Use the LaTeX soul package to highlight text in a LaTeX document.

Suppose you want to provide a highlight color or background color for text in a LaTeX document. A good example is when you want to highlight the background yellow, so it looks like it was highlighted with a marker, to catch a reader's attention. "How do you do this in LaTeX?" you ask.

Normally I like to answer "simple", but in this case there is a multi-step answer. It's still pretty easy, but you'll need to download a package named "soul".

LaTeX table/figure FAQ - How do I reference a table or figure in a LaTeX document?

Being able to automatically reference a figure within a LaTeX document is a very cool thing. This referencing capability lets you easily give readers the exact number of a figure, or tell them what page number a figure is located on with the use of a few simple commands (\label, \ref, and \pageref). The same technique works for referencing other objects within a LaTeX document, including tables and equations.

Here's an interesting page at Wikipedia, where they discuss all of the caching things they've implemented to improve performance:

Here's a Bourne Shell (sh) script I use to run a Java anti-spam program I wrote. The program I'm running isn't important, but what is worth sharing about this shell script is how I dynamically build the Java CLASSPATH by including all of the jar files in the lib directory.

Other parts of the shell script (showing a shell script for loop) may be worth sharing as well, but I think that building the Java classpath dynamically in the shell script is probably the most important part.

With that being said, here's the shell script:

Someone asked me the other day how they could search for files with different names with one Linux find command. They wanted to create a list of all files that ended with the extensions .class and .sh.

Although this is actually very easy to do with the find command, the syntax is obscure and probably not well documented, so let's look at how to do this.

Here's a link to a a quick tutorial/tip I wrote on using the Java Preferences API. I had never used it before, but got this example working in less than 15 minutes (so you know it's pretty easy).

Linux shell script FAQ: Can you share a Linux shell script while loop example? While you're at it, can you show how to use the sleep command in the shell script while loop?

Sure. As a little background, I've written a program I call an Email Agent that periodically scans my email inbox, and does a lot of things to the inbox, including deleting the over 6,000 spams that I receive in a typical day. A recent problem with the Agent is that it runs too fast, apparently overwhelming the sendmail process on the machine that it runs on.

As each day passes I use Cygwin more and more. One of the things I like to do on Unix platforms is to control what my command prompt looks like. On Cygwin, I edited my .bash_profile to include a multi-line entry like this:

PS1='
$PWD
yo: '

This may look bizarre, but I like the results. It makes my command line prompt look like this:

While digging through an old book this morning, I ran across this bumper sticker message from the 1960's:

"An atomic war could ruin your day"

I was born in '63 and don't remember most things like this, but it must have been an interesting time.

 

Linux command line FAQ: How can I record the input and output of my Linux command line (i.e., the Linux commands I type, and the output from those commands)?

I did something wrong in a previous blog entry that led me to use the "pax" command to create a large backup/archive. There's nothing wrong with using the pax command -- other than the fact that it's not available for Cygwin -- and I really needed to created a huge archive. (I know that pax is available for our Linux and Unix systems, but I can't find a version for Cygwin.)

Over the weekend I downloaded and installed the Glimpse search utility on my Windows laptop. Actually, what I'm doing is running glimpse under Cygwin. Because glimpse is generally just available as a source code distribution, I looked around and found a reference to a user who installed it under Cygwin. With that as my encouragement, I downloaded the glimpse source code and had at it.

Just cleaning off an old PC that I used to use, and I find these URLs that some of our developers put together for an old "Java Performance Tuning" seminar:

Here are several Linux-related links from a Computer Shopper that I'm about to throw out. They did a nice little story on how non-techies can try to get Linux going on a PC.

This is a little bit of a stretch, but if you look at the "CSD" doc for this jGrasp project from Auburn, I thought it was interesting that they are essentially trying to apply Edward Tufte sparklines to an IDE. The basic URL for the jGrasp project is:

and the URL for the CSD doc is:

I'm finally getting back into the swing of things after being a presenter at the Borland Conference. To that end I'm making my papers and presentations available online at the following URLs. I think the titles of the papers are self-explanatory, so I'll just list them here.