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

Mac Java FAQ: I'm currently using Mac OS/X 10.4 with Java 1.5.x. But, for a certain application I need to use a previous version of Java, which I can see is actually installed on the hard drive. Can I use this older Java JVM on Mac OS X 10.4?

Answer: Yes, I was able to do this. The hardest part about this is finding where the previous Java version is installed. There are probably easier ways to do it, but I ended up using the Mac mdfind command, which is the command-line version of Spotlight.

By default, when you create a JFrame in a Java client-side application, and the user presses the exit button on the JFrame, the JFrame window is closed, but the application continues to run, essentially running in the background, as you typically don't have a way of showing that JFrame again.

Summary: How to add a manifest file to a Java jar file.

I just created an executable jar file for a Java client-side application. I hadn't done this in a while, and I always forget about the option to include a manifest file in the jar file. If you're good and remember to include a manifest file, like this:

jar cfm curtain.jar Manifest.txt com/

then users can run your client application very simply, like this:

I recently created something that I think is a new user interface feature. (What's the saying ... if you haven't seen it before it's new to you(?).) I call it a "curtain", as it is essentially a visual curtain between the window of the application you're working in and the rest of your desktop. You can check it out at this URL.

Every once in a while someone will give me a large collection of images (JPG, PNG, GIF) that I need to either look at or print. On the Mac (and recent versions of Windows) there are now tools to look at a group of images, but I still like a little program that I wrote.

I wrote this program in Ruby, and what it lets you do is combine all of your pictures into one web page. Then, with the use of CSS, the HTML document you create lets you print each image on a separate page.

I've created a "predictive text" (type ahead) text editor using Java (a JFC/Swing GUI) that attempts to predict what you're about to type. If you'd like to see it in action -- and learn more about it -- you can find it here: my Java predictive text (type ahead) editor.

Mac OS X FAQ: How can I get access to the full path of the current Finder window? That is, when I’m looking at a Finder window that’s showing the contents of a directory like /Users/Al/foo/bar, how can I easily put that directory path on the clipboard so I can use it in other applications?

Mac OS X Terminal/Finder tip: This tutorial shows how to open a Mac Terminal window in the current Finder folder by using AppleScript.

For a while I have wanted to be able to open a Mac Terminal window in the same directory as the Mac Finder folder that I’m currently looking at. I couldn’t find any other way to do this, so I finally wrote an AppleScript script to do it. Fortunately the script is pretty simple. Here's the code:

Mac Terminal Finder FAQ: How can I open a Mac Finder window from the current directory of a Mac Terminal window?

To open a Finder window in the current directory of your Mac Terminal just issue this Mac open command:

open .

Yes, that is a decimal after the open command. The decimal is the Unix way of referring to the current directory.

If you want to use a self-signed certificate with a Java client, follow steps similar to this:

Recently I ran into a programming situation where I needed to select a node in a Java JTree from my code. As opposed to the usual situation of responding to a user's click on a JTree node, I needed to set the active JTree node based on something that was happening in another area of the application.

Wow, if only 10% of the comments on this page are accurate, there is a huge amount of trouble and turmoil at Microsoft on the Vista project. This blog posting makes me feel even better that I just made the switch to the Mac world.

This post is terrific:

What's the difference between OS X and Vista?
Microsoft employees are excited about OS X...



If you’ve never read the book Use Case Driven Object Modeling with UML by Doug Rosenberg and Kendall Scott, you’re missing one of the most simple and important Model-View-Controller (MVC) diagrams in the software business.

In their discussion of Robustness Diagrams they introduce a figure called “Robustness Diagram Rules” that succintly tells you how to implement an MVC design in your code. In one figure they tell you:

Java jar file reading FAQ: Can you show me how a Java application can read a file from own of its own Jar files?

Here's an example of some Java code I'm using to read a file (a text file) from a Java Jar file. This is useful any time you pack files and other resources into Jar files to distribute your Java application.

Java - read Jar file example #1

The source code to read a file from a Java Jar file uses the getClass and getResourceAsStream methods:

Java HTTPS client FAQ: Can you share some source code for a Java HTTPS client application?

Sure, here's the source code for an example Java HTTPS client program I just used to download the contents of an HTTPS (SSL) URL. I actually found some of this in a newsgroup a while ago, but I can't find the source today to give them credit, so my apologies for that.

Here is a Ruby mail program that I use to search my IMAP mailbox with combinations of search criteria. It is a mixture of several different Ruby-based approaches I found on the Internet for searching email systems.

Note that you don't need all the comments at the front as I've shown. It's just that I can't remember all the crazy flags that can be used, and at this time I'm not going to take the time to write a better mail system interface, although IMHO a better interface is surely needed.

I don't work in the DOS (Windows command (CMD.EXE)) world too much these days, but I needed to today. The basic problem was that I needed to build an environment variable dynamically. In this case I was trying to build a variable named CLASSPATH from a collection of Java JAR files in a sibling directory named LIB. This variable had to be built correctly for my Java application to work properly.

SVN directory FAQ: How do I move a directory with subversion (svn)?

svn directory move example

Moving a directory (or file) with Subversion (SVN) is very easy, you just need to use the "svn move" command. Let's try a simple example.

Suppose you have a directory named foo, and you want to rename it to bar. The svn move command to issue is:

CVS login FAQ: How do I login to a CVS server using SSH?

cvs login - a Windows example

Here's how I do a "cvs login" to our CVS server using SSH, on a Windows PC:

cvs login

Note that the only real different thing here is that you specify the ssh protocol for communicating with the server.

MySQL database FAQ: Can you share an example MySQL database schema (i.e., a MySQL database create script).

For what I do I often need a sample database. For my current writing I decided to use the "coffeebreak" database defined in Sun's JDBC tutorial. If it saves you any time in your work, here are the commands. I've only tested these with MySQL, but they should work with most other databases.

Before worrying about the schema, here are three steps that you'll want to do first: