Welcome!

Java Authors: Lori MacVittie, Yeshim Deniz, Mike Kavis, Elizabeth White, Liz McMillan

Related Topics: Java

Java: Article

Mac OS X & Java - A perfect marriage

Mac OS X & Java - A perfect marriage

Mac OS X sports a new look, not just on the outside with its great look and feel but also on the inside. OS X is proudly built on top of a BSD Unix-based core foundation. An exciting aspect of the new operating system is that the latest version of the Java 2 platform (J2SE v1.3) is preinstalled in every Macintosh notebook and desktop preloaded with OS X. (The current release is 10.1, however, in this article I’m referring to the latest version of OS X, v10.1.1.)

This dramatic shift in Apple’s strategy toward Java support in Mac OS could jump-start the deployment of Java-based applications and services on a user-friendly consumer operating system, specifically with the issues surrounding Java support in the new Microsoft operating system, Windows XP. This article reviews the features of Apple’s Java implementation and explores what makes OS X a great operating system for the development and deployment of Java-based applications.

Introducing Mac OS X
OS X is what a lot of developers want – a familiar Unix-based core with a highly productive and great-looking user interface. Built on top of BSD Unix, OS X represents a significant change from its predecessor, Mac OS 9. Darwin, the core of the operating system, combines the services provided by Unix and the Mac 3.0 kernel with support for high-performance networking capabilities. Apple took a big step toward the adoption
of Darwin by making it an open source project (www.darwin.org). Darwin supports a flexible model that in turn supports multiple file systems, including a Universal File System, ISO 9660 (for CD-RW disks), Universal Disk Format (for DVD volumes), and Mac OS Standard HFS. Key to Darwin is support for standards-based connectivity including TCP/IP, PPP, HTTP, FTP, DNS, DHCP, LDAP, and NTP.

Layered on top of Darwin are three graphics subsystems:

1. Quartz: A lightweight window server and PDF-based 2D graphics rendering library

2. Open GL: A 3D rendering model

3. QuickTime: For multimedia capabilities

To provide compatibility with its predecessor, Mac OS 9, OS X also supports a “classic” mode, which makes the system available in a dual operating system mode by running both the OS 9 Classic and OS X operating system. (It’s actually possible to configure OS X to boot with the two operating systems at start up to avoid the delay of a later start up.)

From a development perspective, OS X provides multiple options – Carbon, the traditional Mac OS API that supports completely backwards compatibility with OS 9, and Cocoa, Apple’s next-generation development framework for OS X “native” applications. A key component to OS X and the focus of this article is Apple’s support for the latest version of the Java platform. OS X 10.1 supports Java 2 Standard Edition (J2SE) version 1.3.1, and HotSpot, the latest production version available for Java deployment. Java is treated as a first-class citizen in OS X and, along with Cocoa, is expected to represent a key framework that developers will mostly adopt to build applications for OS X.

The beauty of OS X is its most visible piece, Aqua, OS X’s new user interface. Even though Mac OS is traditionally known for its ease-of-use and intuitive GUI, Aqua makes OS X stand out and represents a dramatic user-interface paradigm shift for an operating system. (Figure 1 shows the various components of the OS X architecture.) A key highlight of Aqua is the intuitive dock (as shown in Figures 2–4 toward the bottom of the screen). Having worked in multiple user-interface environments before, I found Aqua has a huge leg up with respect to usability and user friendliness.

OS X and Java
As we’ve seen in the previous section, support for Java in OS X is strategic to Apple’s new operating system. Every installation of OS X includes a preinstalled version of J2SE 1.3 VM runtime and command-line tools. This is important as developers can now back the latest production-quality Java technologies in the core platform. It’s quite refreshing to start a terminal session in OS X and type “Java” or “Javac” and find out that J2SE is preinstalled and configured on the OS. Table 1 summarizes some key environment characteristics of OS X support for Java.

A distinguishing factor is that OS X doesn’t just embed Java into the core operating system, it actually takes the integration to the next level. For instance, a key highlight of OS X’s Java support is the native preemptive multitasking threads support that can have a true impact on the performance of Java applications and allows developers to utilize symmetric multiprocessing-based systems. Another great runtime extension to Java in OS X is the ability to share class files and HotSpot compiled code across multiple invocations of the virtual machine. Implications of this feature can be significant, as it can be a boon to interactive Swing-based applications, which are typically memory intensive. Shared code can remove a lot of the overhead associated with reloading the large number of classes required for production-quality Java applications.

Key Highlights of Java Support in OS X

J2SE 1.3: Includes the HotSpot Java Runtime Environment (JRE), Java compiler, and other command-line tools.

OS X Look and Feel: An Aquafied implementation of Swing on OS X that gives Swing applications the brand new OS X look and feel.

Java Web Start: An exciting new technology that holds a lot of promise (see Sidebar). To use Java Web Start on OS X, you can use applications developed by third-party vendors who use this technology. For instance, UML-based modeling has gained wide acceptance in the developer community. ArgoUML, an open source UML-based modeling environment, is quite useful and is packaged as a Java Web Start application. Figure 2 shows ArgoUML in action with Java Web Start.

QuickTime for Java: A set of cross-platform APIs that allows Java developers to build multimedia, including streaming audio and video built on top of QuickTime 5, into Java applications and applets.

Java Spelling Framework for OS X: A set of JavaBeans that adds spell-checking to Swing applications.

Java Speech Framework for OS X: A set of JavaBeans that adds speech synthesis and speech recognition to Java applications.

Cocoa Application Framework: An evolution from NeXTStep APIs, Cocoa is a collection of advanced, object-oriented APIs for the development of Aqua-based applications for OS X using Objective C and Java. Apple includes a set of Java classes that allows Java developers to build multimedia-enriched applications based on the OS X-specific Cocoa framework.

Interface Builder: Another tool that’s part of the Developer Tools CD, it can visually create the user interfaces used by Cocoa applications, then the associated event can be linked using Java code. The rule of thumb is to use Swing-based components for cross-platform compatibility, and Cocoa to utilize Aqua-based interfaces and target OS X-specific deployments.

Project Builder: Supports Java development in Apple’s Project Builder IDE.

JNI: Supports invoking native OS-specific API and embedding Java into native applications using standard Java Native Interface (JNI) programmer interfaces.

JDBC: Pure Java (or Type 4) JDBC drivers can be used to access database systems such as Oracle.

Developing Java Applications Using OS X
OS X is very Unix-friendly as a development environment. All the utilities that we’re familiar with on other Unix platforms (typically Sun Solaris, HP-UX, and Linux-based servers) are available in OS X. This benefits developers who intend to use traditional Sun Solaris, HP-UX, and AIX environments for high-end Java deployment but would like to have the ease-of-use of OS X. For a lot of developers (including me) who still like to use command-line tools, there’s good news: vi and emacs, along with other Unix-style utilities such as awk, sed, and shell scripting (OS X includes multiple variants of shell implementation including sh, csh, tcsh and zsh), are all included in OS X. For developers who like the power of X-Windows, a port of X-Windows System is also available for
OS X.

If you work with tools such as vi/emacs to develop Java code, you don’t need any further coaching. Start a terminal session in OS X and you’ll be in a familiar shell interface (tcsh). However, if you’d like to take advantage of the benefits of an IDE, OS X presents several options at the core with Apple’s own Project Builder toolset. (Figure 3 shows Project Builder debugging a simple Java application.) Project Builder is Apple’s IDE for Mac OS X and is designed to support multiple development frameworks and languages. It supports C, Objective C, C++, and Java development using Carbon and Cocoa frameworks and Java, and also includes a new set of application-packaging mechanisms for easy distribution.

Project Builder is available on the Developer Tools CD, which is included with every shipment of OS X. From an IDE perspective, Project Builder supports core features, including workspace-based project editing, source-code management based on CVS, search and navigation, file editing, and building, running, and debugging facilities. From a Java developer’s perspective, Project Builder supports the Java class browser and the WebObjects platform, and has the integrated ability to create clickable applications for the OS X platform. Its great performance and ease of use are instrumental in its usability.

Apple Project Builder
Apart from the core facilities of an IDE, Project Builder is pretty basic. For users interested in using an integrated user interface design, integrating with UML modeling tools, and wizard-based application generation capabilities, OS X has support from a host of third-party vendors and organizations. Borland recently released JBuilder 6.0 for Mac OS X for developing and deploying Java applications, JavaBeans, applets, JSP, and servlets. It features an integrated set of tools including an editor, debugger, compiler, and visual designer. Apart from this, Code Warrior from Metrowerks is a popular IDE on a Mac environment. NetBeans, the Java-based open source IDE from Sun Microsystems, has been successfully tested on the OS X platform (www.netbeans.org provides the instructions to run NetBeans on OS X). Running Forte for Java 3.0, a commercial IDE based on NetBeans 3.2 technology, is very similar. Since OS X completely supports J2SE 1.3.1, you can potentially use any other IDE built using Java as well.

Server-Side Java and OS X
As the name suggests, OS X Server is the server version of the OS X operating system. Key highlights of OS X Server include support for file-sharing services using Apple AFP, Windows (using Samba), FTP, NFS, Mail (IMAP, SMTP, POP3), and print services; Web services using Apache Web Server with WebDAV, PHP, CGI, WebObjects, and SSL support; QuickTime-based streaming media services; and open standards–based TCP/IP services, including DNS, DHCP, SLP, LDAP, graphical installation, configuration, and administration.

Mac OS X Server (version 10.1) extends the philosophy of using and embedding Java technologies. It automatically installs a preconfigured version of Apache Web Server (version 1.3.20) and Apache Jakarta Tomcat (version 3.2.3), the most popular reference implementation of server-side Java technologies (servlets and JSP in the /Library/Tomcat folder). To configure the OS X Web Server to work with Tomcat, uncomment the three lines in the Apache configuration file (etc/httpd/httpd.conf) to load the mod_jserv module, run Tomcat (/Library/Tomcat/bin/tomcat.sh), and restart the Web server using the server administration tool. Optionally, the Web server root can be set to Tomcat root application directory (/Library/Tomcat/webapps/ROOT/) to test the Tomcat instance. Figure 4 shows Tomcat in action on OS X and the Web server administration interface.

Keep in mind that the bundled Tomcat installation is version 3.2.3. If you need support for the new Servlets 2.3 and JSP 1.2 API (part of J2EE 1.3), download the latest version of Tomcat (v4.0.1) from http://jakarta.apache.org/tomcat. It involves replacing the 3.2.3 folder with the latest version and updating the httpd.conf configuration file with the new mod_webapp module provided by the Tomcat 4.0.1 binary distribution.

Tomcat can not only be used to serve dynamic Java applications from OS X, but can be a very effective local testing tool as well. It’s worth noting that even though we were discussing OS X Server, Tomcat and other server-side application engines can be seamlessly executed on a regular OS X operating system as well; OS X Server just makes the step easier with an embedded installation/configuration. From Apple’s perspective it would be nice to make Tomcat configuration/administration seamless from the server console, similar to the way it’s done for other services such as Apache Web Server and FTP Server. TomcatX (http://homepage.mac.com/rlaing/TomcatX.html ), a simple Cocoa-based graphical utility, was also useful in starting Tomcat instances.

Beyond Tomcat: J2EE
Since OS X completely supports J2SE 1.3, other third-party J2EE application servers such as Orion and JBoss, which are completely written on top of Java, can be used to develop and deploy J2EE applications on an OS X platform as well. For instance I successfully tested the latest version (1.5.2) of the Orion Application Server (which is also the key constituent of Oracle’s J2EE application server) on my OS X Server installation. The Orion Application Server (www.orionserver.com) is a freely available (for development purposes) J2EE-based application server and implements key J2EE technologies including EJB, JNDI, JTA, JMS, JDBC, JSP, and servlets. Apple’s own WebObjects platform, which supports a server-side enterprise Java platform, is expected to move toward J2EE compliance as well. This area needs greater focus from Apple and third-party application server developers (such as BEA and IBM) to make J2EE development and deployment smoother on OS X.

Is Mac OS X a Perfect Candidate for Java Development?
It’s clear that Java and OS X are good for each other. Should OS X be your next Java development environment? In this section I’ll explore how OS X maps some fundamental requirements from a developer’s perspective and attempt to map the various tools and technologies around OS X and Java by discussing the key development requirements and key enablers in Apple Mac OS X.

Java Runtime and Development Kit (Including Compilers)

OS X embeds J2SE version 1.3.1 with the HotSpot Client VM.

Support for J2EE-Based Application Servers

Apache Jakarta Tomcat, which implements the JSP and Java servlets component of J2EE, is embedded into the OS X Server platform; for nonserver users Tomcat can be easily installed and configured as well.

Other pure Java-based J2EE application servers such as the Orion Application Server and JBoss can be used on OS X as well.

Java Development Tools
Numerous development tools are available, for example:

• vi/emacs

• Apple Project Builder

• Borland JBuilder 5.0/6.0

• NetBeans 3.2 and Forte for Java 3.0

• Metrowerks CodeWarrior for Java

• jEdit

• MightyJ

• Other popular IDEs are expected to follow suit with OS X ports

Database Connectivity Using JDBC
Database connectivity is a crucial aspect of most enterprise application development. Since OS X completely supports J2SE 1.3, JDBC support is built-in. If your database vendor or a third-party supplier has a Type 4 pure Java JDBC driver, you can use that driver with JDBC for OS X. A port of MySQL, a popular database system in the Linux community, is available for Mac OS X (actually OS X Server includes it as part of the installation). Other RDBMS options on OS X include PostgreSQL and InstantDB. Since OS X has roots in BSD Unix, we can expect more database vendors to port their databases natively for the OS X environment.

UML Modeling Tools

As highlighted earlier in the article, ArgoUML, a Java-based UML, is available as a Java Web Start application.

Installation Tools

To aid in the development of installation scripts/programs for deploying Java-based applications, a number of options are available:

• Project Builder–based creation of clickable .app applications

• Installer VISE 7.x from MindVision Software

• Install Anywhere 4.5 from Zero G Software

Ease of Deployment
Key highlights that aid the deployment of Java applications include J2SE with a HotSpot Client VM, support for Java in Internet Explorer, and Java Web Start.

Web Browser with Java Support

Microsoft Internet Explorer and Netscape X 6.2 with the latest Java support are both available on OS X.

Office Productivity Tools

Microsoft has ported Micro-
soft Office for OS X including Word X, PowerPoint X, Excel X, and Entourage X (e-mail collaboration tool). Office is now available on OS X, as it seamlessly makes life easier for Java developers on the Windows platform since they also need productivity tools (documentation, presentations, spreadsheets, etc.) apart from Java development. OpenOffice, a port of the open source office toolset, is underway as well.

Hardware
Apple is known for great hardware. Not only from the outside but also from the inside. For instance, my choice for running OS X would be the sleek Titanium PowerBook G4 Notebook. Powered by a fast 66MHz PowerPC G4 processor, 48GB hard-disk drive, support for up to 1GB of RAM, a slot-loading CD-RW/DVD drive, built-in wireless LAN support through Airport, and an almost infinite expandability option with FireWire and USB support, the 1 in. thick and 5.3 lb portable notebook with 15.2 in. display has everything a developer could dream about. And you can always make your family and friends feel good by creating movies and DVDs using Apple’s iMovie and iDVD software when you’re not developing Java applications.

Conclusion
OS X marks a revolutionary step toward usability and ease of use for a productive and a user-friendly operating system. With its built-in support for the latest version of the Java platform and the key benefits it brings to the table, including the excellent hardware, Microsoft Office, and built-in wireless connectivity, OS X is definitely a candidate for your next operating system for building and running enterprise-class Java applications.

References

Apple Mac OS X: www.apple.com/macosx/

OS X Developer Community: http://developer.apple.com/macosx/index.html

Apple Java Developer Community: http://developer.apple.com/java/

Java Web Start: http://java.sun.com/products/javawebstart/index.html

ArgoUML: http://argouml.tigris.org

JBuilder on OS X: www.borland.com/jbuilder/mac/

Mac OS X Server: www.apple.com/macosx/server/

WebObjects: www.apple.com/webobjects/

More Stories By Hitesh Seth

Hitesh Seth is chief technology officer of ikigo, Inc., a provider of XML-based web-services monitoring and management software. A freelance writer and well-known speaker, he regularly writes for technology publications on VoiceXML, Web Services, J2EE and Microsoft .NET, Wireless Computing & Enterprise/B2B Integration. He is the conference chair for VoiceXML Planet Conference & Expo.

Comments (13) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
DV 04/23/02 04:58:00 PM EDT

Unlike the first Apple-- list price: $666.66

initgraf 04/23/02 03:37:00 PM EDT

I can't really comment on the JDK1.4 comment, but you mentioned that InterfaceBuilder doesn't support Swing. It never will (and thank God for that). InterfaceBuilder is primarily for Cocoa apps and has been retrofitted for Carbon apps. Swing and Cocoa programming (which can be done in Java, but Objective-C is much better) are about as close to each other as MFC (Microsoft Foundation Classes) and Perl. They aren't! The best Java RAD apps can do with Swing is code generation (which usually takes a roundabout approach to putting the GUI together). InterfaceBuilder generates no code. The GUI elements you drag from the palette are actual objects instantiated and manipulates at runtime. When you save your .nib file, you are actually archiving the object hierarchy that makes up the GUI for your app into a file. That file is can be loaded (and thus unarchived) at runtime, with all the connections between the GUI widgets and your app-specific classes intact. This approach is much better than Swing IMHO. Get even the most complicated GUI fully functional in minutes and never have to worry about how optimized the code generation was. If you need to make dynamic changes to the GUI at runtime, the GUI objects have methods for that too. For Apple to make InterfaceBuilder generate Swing code would contradict the original purpose of the program: to make GUIs effortless to create and change. Besides, the Swing (and Java) event model is completely different than Cocoa's. There isn't an aggregation of EventListener interfaces in Cocoa. Every on-screen widget can be subclassed to override low-level events such as mouse and keyboard events. Instead of an ActionListener interface, each clickable widget has a target and an action. The target can be whatever object you want (regardless of class), and the action can have any name (instead of actionPerformed()). And what's better is that the target and action and classes that will contain them can be created and graphically linked to the proper GUI widgets without writing any code all inside of InterfaceBuilder. If you want a Swing code generator, there are plenty of available apps to choose from that will run on MacOS X. InterfaceBuilder is too sophisticated for something like that. Just my $.02

CORY MARTIN 04/19/02 10:31:00 PM EDT

hello im a new mac user i got the new imac and i love it.i I like to get some screenshots if i could i did pay 4 a book i did not get? from apple im in nova scotia canada
11 david st.
b1a 3z2
but some screenshots wow would be nice

oh by the way did i say .....I LOVE IMAC
this is coming from a person who has used a PC now for 10 years and mac is the way to go ...4 now on im mac 4 life
thanks 4 any help you send me :) HAVE A GOOD DAY

cory martin

Steve Evans 04/18/02 12:07:00 PM EDT

The correction should be 667 MHz not 666MHz nor 66 MHz for the top end PowerBook G4. I think Apple may have done that to get away from the negative associations with the number 666.

Jacoby Thwaites 04/16/02 03:30:00 PM EDT

That's right - Apple's got a LOT of catching up to do with Java. Key gripes:

1. JDK is behind Windows
2. Developer Tools needs much, much more Java support (NetBeans works and is v. v. powerful but is ghastly to use in comparison)
3. No Java 3D
4. Interface Builder with Dev Tools has no Swing support. This is a real downer.
5. Dev tools has no neat wizards for Servlets/JSP, RMI, JINI or any of the latest Java stuff (s'pose this is the same as 2)

etc.

Nonetheless, you'll never, ever get me onto a PC.

Not only that, but I've made 2 conversions to the cause in the last 2 weeks with my TiBook + OS X.

palec 04/14/02 04:05:00 PM EDT

Latest version JDK is 1.4 but not for Mac :-(

jmacmullin 04/11/02 09:33:00 PM EDT

If you're looking for an easy-to-use IDE for Java programming on Mac OS X - why not try JJEdit - http://homepage.mac.com/jmacmullin/

horacio 04/11/02 08:23:00 AM EDT

goddamit guys! pb titanium is 6670 mhz!

fivenorth 04/10/02 05:06:00 PM EDT

Dudes!

It's 667 MHZ! Geez...

Aaron Yates 04/10/02 03:10:00 PM EDT

Not 66mhz or 666mhz 687mhz

Peter Leing 04/10/02 12:42:00 PM EDT

In the paper version of this article you state that the Titanium PowerBook G4 has a 66MHz PowerPC G4 processor, it should be 666MHz.

Mason 04/10/02 12:27:00 PM EDT

Latest version is 10.1.3, not 10.1.1.

Florentin Westermann 04/09/02 03:43:00 PM EDT

By the way, i saw that you made screenshots with the Application "Grab".
It goes easier.
Press "Command shift 3" (without ") for a screen grab or "command shift 4" and select the part of the screen which you want to "grab"

regards,
florentin