O'Reilly logo

QuickTime for Java: A Developer's Notebook by Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 1. Getting Up and Running with QuickTime for Java

Do you need to do anything special to start developing QuickTime for Java applications? The answer to that question is easily answered by another question: are you using Mac OS X? If so, you have everything you need: Java, QuickTime, and QuickTime for Java (QTJ). If you’re using Windows, you might have some downloading to do.

Setting Up QTJ on Windows

First, you must have Java installed, presumably the latest developer kit release from Sun. As of this writing, that would be the J2SE 1.4.2 SDK, which lives at http://java.sun.com/j2se/1.4.2/download.html. Now you must install and/or update QuickTime.

How do I do that?

If you don’t already have QuickTime (or iTunes, which includes QuickTime in its install), you can get it from http://quicktime.apple.com/. What’s perhaps more common is that you have QuickTime, but you don’t have QuickTime for Java, which is not installed by default.

In this case, you can use the QuickTime Updater to update your copy of QuickTime and install custom pieces like QTJ. If you have the QuickTime icon down in your System Tray, you can right-click it to launch the Updater, as seen in Figure 1-1. You can also get to the Updater via Start Programs QuickTime QuickTime Updater.

Launching the QuickTime Updater from the system tray

Figure 1-1. Launching the QuickTime Updater from the system tray

Whether you’re updating or installing QuickTime for the first time, you need to click the Custom button to perform a custom install. This will give you the opportunity to install nondefault features, most of which are optional codecs , or software components to handle various video and audio encoding formats. Scroll down the list and you should see QuickTime for Java, as shown in Figure 1-2.

Custom install of QuickTime for Java

Figure 1-2. Custom install of QuickTime for Java

Continue by clicking Update Now (or Install, if this is a new install) to put the latest version of QuickTime and QuickTime for Java on your PC.

What just happened?

The installer installed QuickTime’s various pieces in your system, adding a QuickTime group to your Start Menu, a QuickTime icon in your System Tray, various pieces in C:\WINDOWS\System32\QuickTime, etc. It puts QTJava.zip in the lib/ext directory of any valid Java installations it finds, adds a systemwide environment variable called QTJAVA with the path to this file, and adds the file’s path to the CLASSPATH system environment variable, creating it if necessary. Figure 1-3 shows what this looks like in Windows Explorer.

QTJava.zip file installed into a Java 1.4.2 lib/ext folder

Figure 1-3. QTJava.zip file installed into a Java 1.4.2 lib/ext folder

It should be obvious that it’s important to do the installs in the order shown here: Java first, then QuickTime. That way, QuickTime can find the existing Java directories into which to install QTJava.zip. Unfortunately, this can still get messed up if you add another Java Runtime Environment (JRE) later—QuickTime might think QTJ is installed, but the new JRE won’t have QTJava.zip in its lib/ext directory. In this case, copying QTJava.zip manually might be the most practical option.

Note

Note that QTJava is a zip file, not a JAR, which gives it this archive-like icon. You don’t need, or want, to ever unzip this file.

What about...

...installing QTJ on Linux? Sorry. The thing that makes QTJ fast and powerful—the fact that it’s a wrapper to an underlying native framework—is also its cross-platform downfall. QuickTime for Java can exist only on platforms that Apple develops QuickTime for, and right now, that means Mac and Windows. On the other hand, if Apple ever did port QuickTime to Linux, bringing QTJ along for the ride probably wouldn’t be hard.

And what about installing QTJ on (Classic) Mac OS? Of course. QTJ was originally developed on and for Mac OS 8 and 9. It is part of the standard QuickTime install for Mac OS and thus gets picked up as part of a regular update (which you’d launch with the QuickTime Settings control panel, under the Update Check section). On Classic, the QTJava.zip file lives in System Folder/Extensions/MRJ Libraries/MRJClasses (yes, there’s a space in MRJ Libraries , but not in MRJClasses).

Note

MRJ means Macintosh Runtime for Java, the name of Classic’s JRE. The name and its confusing versioning were dropped for OS X.

However, development of QuickTime for Classic stopped at Version 6.0.3 and does not include the much-changed version of QTJ that this book covers, QTJ 6.1. Furthermore, it’s worth remembering that Java on Classic Mac OS never got past Java 1.1.8, which means it doesn’t include Swing, Collections, or many other J2SE classes and conveniences that modern Java developers would expect to be present.

Where’s the API documentation? Even though QTJava.zip is all you need to compile, some documentation and demos would be really helpful, right? The good news is that there is a QTJ SDK that offers Javadocs and demos. Unfortunately, much of what’s on Apple’s web site as of this writing refers to an earlier version of QTJ that won’t work with Java 1.4 on Mac OS X. The most complete SDK right now is labeled as the “QuickTime for Java Windows SDK,” and is located at http://developer.apple.com/sdk/index.html#QTJavaWin. This package contains a complete set of current Javadocs and demos that have been updated to represent the new API calls in QTJ 6.1. You can also view the Javadoc online at http://developer.apple.com/documentation/Java/Reference/1.4.1/Java141API_QTJ/index.html.

Tip

When you look at the Javadoc, many methods will have a boldface reference to their equivalent C function. For example, Movie.start( ), which starts playing a movie (see the next chapter), wraps the native function QuickTime::StartMovie. You can usually find the native documentation by doing a search on Apple’s page for the function name or by Googling for it with a search term like site:apple.com StartMovie.

Why would you ever look at the native docs when you’re programming in Java? Because a lot of the parameters aren’t described in the Javadoc, particularly when methods take behavior flags.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required