alvin's blog

Sample Mac Jar Bundler Ant build script

I was going to write a little tutorial on how to use the Jar Bundler Ant task for Mac OS X, but I don't have the time to do that right now.

So, I'll just share my Mac OS X Java Ant build script, which includes the JarBundler task. You should be able to use this Ant build script to build a Java application so it appears to the user to be a native Mac OS X application, even though it's really a Java application under the covers.

AppleScript error: Can't make (handler) into type string

If you ever get the following error message in an AppleScript program (at least while editing the program in the ScriptEditor):

Can't make (handler) into type string

fear not, it seems to be pretty simple to cure. In my case I got this more-specific error message:

Can't make (handler getDayOfWeek) into type string

This error just means that I tried to call a function like this:

Linux cat command tutorial (and examples)

Linux FAQ: Can you share some examples of the Unix/Linux cat command?

The cat command lets you view text files. If you're familiar with MS-DOS, the cat command is similar to the DOS type command.

However, the cat command gets its name from the word concatenate, and as that name implies, it lets you merge several files together, as you'll see in the examples below.

Linux du command examples

Linux disk usage FAQ: How do I show disk usage information on a Unix or Linux system, such as how large a directory is?

The Unix and Linux du command shows information about "disk usage". Whereas the df command ("disk free") shows information about Linux filesystems, the du command shows disk usage information about only the files and directories you specify.

How do I sort a Unix directory listing by file size?

To sort a Unix / Linux directory listing by file size, you just need to add one or more options to the base ls. On Mac OS X (which runs a form of Unix) this command works for me:

ls -alS

That lists the files in order, from largest to smallest. To reverse the listing so it shows smallest to largest, just add the 'r' option to that command:

ls -alSr


JButton focus - How to put initial input focus on a JButton

Question: In a Java Swing application I open a JFrame that displays some contents in a JTextArea, and has a Close button (a JButton) at the bottom of the JFrame. I've tried a lot of things, but I can't get initial focus on that JButton component. This is happening on a Mac OS X system, but I'll assume it has the same problem on Windows. Any suggestions?

Create Mac "icns" icon files with Icon Composer

If you need to create icons for an application on a Mac OS X system, Apple provides a small application named "Icon Composer". If you have the Xcode tools installed, this application is in the /Developer/Applications/Utilites/Icon Composer folder on your system. (Choose Macintosh HD, then Developer, Applications, Utilities, and then the Icon Composer application.) More to the point, this utility program helps you create icons in Apple's "icns" format from icon images in other formats.

Syndicate content