Initium RJS: A Macintosh Screensaver in Java, Part 3

By Douglas A. Lyon, Pawel Krepsztul and Francisco Castellanos

space COLUMN

PDF Icon
PDF Version


We describe how to create a Java-based screensaver for a Macintosh. A screensaver is a program that automatically runs when the computer enters a quiescent state. Screensaver frameworks enable CPU scavenging. CPU scavenging enables the use of otherwise wasted CPU cycles.

Screensavers are a minimally-invasive technology for volunteering CPU services. Computers typically have 23% utilization (40 out of 168 hours, per week) or less. Screensaver-based cycle scavenging improves utilization dramatically.

This paper is part 3 of a 5 part series on Java-based screensavers. Parts 1 and 2 addressed the creation of screensavers on Ms Windows and XWindows platforms. These screensavers are a part of the Initium Remote Job Submission system (Initium RJS). Initium RJS is a joint project between DocJava, Inc. and Fairfield University. The goal of the Initium RJS system is to make grid-based computing, in Java, a little easier.



This paper is the 3rd in a series on screensavers in Java and describes the application of our technology to the Macintosh platform. Our previous papers covered the Windows and Unix platforms. With this paper, we have covered Java-based screensavers on three major platforms. Our goal is to make use of these screensavers in the Initium RJS system, our grid-computing framework.

We show how to create a screensaver using a custom framework. Our past work described an existing framework, called the SaverBeans development kit, an open-source, freely-available framework consisting of both C and Java code. The kit is available for both the MS Windows and Linux systems. However, it is not available for the Macintosh. The alternative to creating a Macintosh-based screensaver is to run X-windows under the Macintosh. Our impression is that this is an idiosyncratic use of the Macintosh, and users prefer a solution that makes use of the native window manager (quartz) of the Macintosh.


The Macintosh has a development IDE available for simultaneous creation of both Objective C and Java programs. The IDE is freely available, as a part of the XCode distribution and is called ProjectBuilder.

The basic idea behind our screensaver is that it will run a Java Web Start Application. This enables deployment of updates to our screensaver without having to reinstall it.

We start with an Objective C program (a file with a .m suffix), inspired by [Christensen]:

The screensaver runs a computation server using the RunCS class . The RunCS constructor is created with a String argument. If the argument is equal to "start", then the startCs method is invoked. The method checks to see if the semaphore file, killcs exists, and deletes it, if it does. A thread checks the file, and if it exists, the computation server is terminated. The semaphore file is stored in a temporary directory. If the argument to the constructor is "stop" then the stopCs method is invoked. The stopCs method creates the killcs file to trigger termination. The screensaver (written in Objective C) invokes the Java program using an objective C to Java bridge [Lyon and Huntley] [Monitzer].

2.1. Installing The Screensaver

We have created a web start method for automatically deploying and installing the screensaver to a Mac. The URL is available at and provides for an installation using a technique we call beaming over the files. The basic idea is that the screensaver files are transferred from the web server to the local disk. There they are uncompressed and placed into the proper location for user screensavers (~/Library/Screensavers/). The code for this type of beam over operation follows:

The dateIsGood method checks the local screensaver installation to see if there were any updates. If the old screensaver is newer than the screensaver on the web server, no download occurs. Once the user sets up the screensaver, it can be tested with a preview command. During preview, the new screensaver starts the Initium RJS Compute Server.

2.3 Deploying

The screensaver.jar mentioned in Section 2.2 has the following files in it:

The file is uncompressed and moved into the users' screensaver folder automatically. The key to this effort is the ability to beam over the resources from a given URL and uncompress them. Beaming a resource from a web server into a local file is a service performed by a helper method in the UrlUtils class:

To unpack the Jar file, we have a class called the Unzipper:


This paper illustrates the details of creating a Java-based screensaver for the Macintosh. The screensaver launches a Java Web Start application upon detection of a quiescent period. Web start applications upload to a web server asynchronously with respect to the screensaver. New web start applications will be automatically downloaded, and verified, by the web start launching framework.

The web start application launched by the screensaver framework is a compute server. The compute server volunteers the spare CPU cycles of the host to the grid. Part 4 addresses the question of how the compute server is able to contact the grid and obtain jobs from the grid framework.

We have also disclosed a beam-over technique that enables the transfer of a screensaver resource from a compressed file stored on the web server. The beam over includes a decompression phase, as well as, an installation phase that places the files into the users screensaver library. Activating the grid screensaver as the default, requires manual user intervention. The question of how to automate this process remains open. Jar verification should help thwart man-in-the-middle attacks on the Jar file during transfer. The question of how to do the verification against a trusted certificate remains open.

The question of how to make a screensaver more like the SaverBeans SDK is left for future work. The introduction of the Intel processor to the Apple line of products required us to recompile the native portion of the code and write new code for detecting the 386 architectures.

The Initium RJS system is available from the web page for the book Java for Programmers [Lyon].


[Christensen] "Writing a Screensaver Module" by Brian Christensen, April 10, 2001,

[Lyon and Huntley] "There's More Than One Way to Build a Bridge", By Douglas A. Lyon and Christopher L. Huntley, Computer, May, 2002, pp. 102-103.

[ Lyon ] Java for Programmers, Prentice Hall, Feb. 2004.

[Monitzer] Andy Monitzer, "The Java Bridge", March 17, 2002,

[Zawinski] Jamie Zawinski: "A screensaver and locker for the X Window System"


About the author

  After receiving his Ph.D. from Rensselaer Polytechnic Institute, Dr. Lyon worked at AT&T Bell Laboratories. He has also worked for the Jet Propulsion Laboratory at the California Institute of Technology. He is currently the Chairman of the Computer Engineering Department at Fairfield University, a senior member of the IEEE and President of DocJava, Inc., a consulting firm in Connecticut . E-mail Dr. Lyon at . His website is

  Pawel Krepsztul earned his Master's Degree in Electrical and Computer Engineering from the Fairfield University in August 2005. His research interests include grid computing. Currently he is employed by Pepsi Bottling Group in Somers, NY as a software developer. He can be contacted at

space Francisco Catellanos earned his bachelors degree with honors in Computer Science at Western Connecticut State University. Francisco Castellanos worked at Pepsi Bottling Group in Somers, NY as a software developer. Currently he is working on a thesis to complete his Master's Degree in Computer Engineering from Fairfield University. His research interests include grid computing. Francisco Castellanos is also employed by Access Worldwide in Boca Raton, FL as a software developer. He can be contacted at

Cite this column as follows: Douglas A. Lyon Pawel Krepsztul and Francisco Castellanos "Initium RJS: A Macintosh Screensaver in Java, Part 3", in Journal of Object Technology, vol. 5. no. 7, September-October 2006, pp. 9-17

Previous article

Next column