ResCafé - Mac Resource Fork Viewer and Extractor
ResPresso - command line version
Version 1.4
"Doing its part to run the coffee metaphor into the ground."
by G. Brannon Smith < >
Introduction & Hype
ResCafé is a Swing-based Java utility for reading and extracting resources such as ICONs and MENUs from the Resource Forks of Macintosh files. It is somewhat similar to ResEdit on MacOS except that it is not an editor; it operates on files in a read-only fashion.

ResCafé was created with one main idea in mind - extensibility. There are so many different types of resources and not everyone is interested in the same ones (though there are some that are probably more in demand, such as Icons). I didn't want to write a parser, what I call a Handler, for all of them, nor did I want to exclude potential new ones or force a recompile to add them. So I've tried to implement a kind of Plugin Architecture which, while awkward in places, seems to work well overall. It even auto-detects new plugins (with some caveats)! Cool!

However, if someone out there knows a lot about plugins in Java apps or the location of a tutorial, I'd love to hear about it.

Along those lines of of extensibility, I wrote ResPresso which is a text-only, command-line program that reuses the ResourceManager package and the plugins as well.

I hope someone will write some cool plugins - mine are kinda boring. I also took this as an opportunity to explore:

  • Swing, which is really cool and powerful once you get to know it; A vast improvement over AWT.
  • the MVC (Model-View-Controller) design framework/architecture/whatever. I hope I'm using it right. It seems to a pretty good way to build stuff, but it can be tricky. I might have kludged it a bit at times.
1.4 -> 1.4.1
Changed to MIT License at the request of Alexei Svitkine
1.3 -> 1.4
Yea! Thanks to some tips from Peter Stuer I finally got the 'icns' plugin working! I can now save 32-bit icons with alpha. I tweaked a lot of the code so it can better locate the plugins and icons directories. The doc menu is now alphabetized and can be traversed with 'Ctrl +' and 'Ctrl -'. Added a new application to the package called ResPresso which is a command-line version much like the original macfork. It reuses the ResourceManager package and the plugin handlers. Very cool.
1.2.5 -> 1.3
Made some minor code modifications to solve problems I was having with Java 1.3. Added an opening splash screen with notifications about the loading procedure. Added the beginnings of an 'icns' plugin. Unfortunately this does not parse the 32-bit components which really are the most important part of 'icns' )-;.
1.2 -> 1.2.5
Completely replaced Jimi with XpmImage for all code including plugins. Also fixed ResCafe top class so multiple files can be loaded on the commandline.
1.1 -> 1.2
Still more fun changes. Added support for mouse click sorting of plugin display columns as well as optimal adjustment of the column widths. Rearranged the plugin class hierarchy so almost all plugins can take advantage of it. Also added a custom XpmImage class that supports mask so icons will be properly exported to XPM files. Added the beginnings of GUI windows to track the loaded plugins and what they can handle.
1.0.1 -> 1.1
More radical changes. Added support for multiple open documents using the new DocumentManager class. Open docs are accessible through a new Documents menu.
1.0 -> 1.01 (NOTE: Unreleased)
Put icon loading and plugin scanning into Java Threads. The result is faster start up. Also added menu shortcuts and mnemonics.
0 -> 1.0
Initial Release
As of 10 Aug 2009, ResCafé is distributed under the MIT License. See it here.
ResCafe PNG screenshot

This screenshot is in PNG format and some browsers can't display it properly (or at all), so if you can't see it or if it doesn't look quite right, try the JPEG version.

  1. Java 1.2 or better - available from Sun or Blackdown. I develop with Java 1.3, but I think Java 1.2 will work. Not so sure about Java 1.1. In any case you will need Java2D available. Surprisingly, one of the best Linux Java VMs out there is by Big Blue. In fact, I would say the leading developer of Java tools for Linux, IMHO, would have to be IBM. And while you're there, check out their Jikes Java compiler. Two words: Suh weet!
  2. Swing classes - also available from the above sources
  3. Java Advanced Imaging (JAI) - available from Sun
  4. Some kind of utility for getting an intact resource fork from a Mac file onto your non-Mac machine. Resource forks have a nasty habit of disappearing when transferring files from Macs and thus require some special handling to preserve them. The traditional method is called Binhex encoding which flattens Mac files into ASCII format. Several Mac utilities, such as StuffIt, CompactPro, or the actual app called BinHex. Once on your platform, you will have to obtain corresponding software to decode. Check your favorite software repository, do an Internet search for BinHex, or just check the Stuffit link above. Linux users see below for an even better procedure.

I think that's it...


This app was written and tested on an Intel/x86 Linux box with some additional testing on a SPARC Solaris box. If you're on another platform... good luck. (And if you're on a Mac, just use ResEdit). BTW I did manage to get it to run on a friends 200MHz 32MB Windoze machine after a lot of hassle and it ran OK... kinda jerky though.

If anyone knows how to write a nice BAT script to run ResCafé I'd love to see it.

  1. Unpack the archive (I guess you already did).
  2. Edit and and fix the ResCafé location. Make sure the ResCafe.jar file is in CLASSPATH. (If you want to recompile, you will have to make similar changes to the main Makefile )

    You might have to make some more serious edits if your JVM complains. Under Solaris I seem to have to explicitly give java the CLASSPATH with a -cp or -classpath option.

    You don't even have to use the shell scripts if you don't want to - non-UNIX users won't anyway and will have to find their own solution (May I suggest installing Linux? ;-) ).

  3. Make sure ResCafe.jar, plugins and icons are under the same directory:
                              |                    +------------+
                 +------------+----------+         | |
                 |            |          |         +------------+
            ResCafe.jar    plugins/    icons/       somewhere...
            |                 |                 |
    SomeHandler.class    AnotherOne/     *YetAnother.jar* - in devel
                |                        |
          TheHandler.class         Support.class      

Also notice you can dump plugins right in the plugins dir, put them in their own subdirs (still under the plugins dir) with additional classes they may need, or stuff them in jar files (again with their helper classes). I'd be careful with this last one - I just got it working and I don't know how well it works. (Actually see below for more on this).

That should be it... if you have a better setup, let me know. Again, is a shell script. If you can't use shell scripts, you'll have to come up with something else, like a .BAT or whatever your platform uses.
Known Bugs & Caveats

    Well, the best icons to use are the ones from ResEdit, but I figure those are property of Apple so I'm not going to redistribute them. I suppose you could get a copy of ResEdit and extract the icons from there with some tool - a tool that could read the Resource Fork of ResEdit, display the icons therein, and save them. Maybe I'll write one - and call it ResCafé...hmmm...

    Of course, some cool custom icons might be better still.
  • JARs of PLUGINS - Above I talked about scanning plugins in jar files. However the Jar Class Loader I used is copyrighted code from the Javaworld site. I need to contact the author about how I can use it. Until then, I don't think I will be including the Jar Class Loading classes in this distribution. ResCafé should notice their absence and politely move along. To get around this, just don't use jar archives of handlers for now.

    UPDATE: The jar loader class skipping code does indeed run - assuming the class in question has already been compiled.

    Unfortunately the JarLoader absence still makes compilation terminate. So I have commented out that code. What you could do is go and grab the classes from and try to hook them in, edit, and recompile to make this work.

    UPDATE: It looks like this feature is being added to the standard Java distribution so I try to bring this back online soon...

Linux and Mac Icons
OK Penguinheads - this one is for you. You don't actually need a Mac to use all the cool Mac format icons (and other stuff) out there on the 'Net. I have figured out a procedure for doing everything right on the good ole Linux box:
  1. First you will need ResCafé (well, duh) following the Requirements section above EXCEPT for requirement (4) which is superceded here.
  2. Next, because many of the Mac archives you will encounter on the 'Net are BinHexed (*.hqx), you will need the Linux BinHex - or rather hexbin - utility of the macutils package, which probably came with your distro. If you can't find it (% which hexbin), check or Freshmeat for similar utilities.
  3. Now here is the linchpin: StuffIt. StuffIt is the standard, albeit proprietary, compression scheme for Macintosh. Once you have hexbin'ed a new file you will most likely encounter a StuffIt archive (*.sit or *.sit.bin) staring back at you. Fortunately, Aladdin has released a Linux version of UnStuff that will expand those files. Actually, this will take care of binhex decoding as well - but I've always just used hexbin. Once installed, it is very important that you call unstuff like this:

    % unstuff -m=on SomeMacArchive.sit

    The -m=on switch will ensure preservation of the resource fork so that ResCafé has something to read.
  4. With this infrastructure in place, go to the best icon site on the 'Net: The IconFactory. There you will find vast stores of (32 x 32) icons. Sometimes, you will see icon sets available for download in two formats, one of which is call an IconDropper pack. Always get this format when you can - it will make things a lot easier with ResCafé since the icons are stored in a single file rather that one file per icon. Once you have a file, you can hexbin it, unstuff it, load it into ResCafé, and extract the icons to XPM or PNG files (with transparency) for use with KDE or some other cool window manager!
Latest version - 1.4.1 (325k) - includes compiled classes and source.
Previous version - 1.4 (325k) - includes compiled classes and source.
Previous version - 1.3 (256k) - includes compiled classes and source.
Previous version - 1.2.5 (265k) - includes compiled classes and source.
Previous version - 1.2 (237k) - includes compiled classes and source.
Previous version - 1.1 (192k) - includes compiled classes and source.
Initial version - 1.0 (144k) - includes compiled classes and source.
$Id: index.html,v 1.6 2009-08-11 02:40:06 gbsmith Exp $

Valid XHTML 1.0! Valid CSS!