Apple Developer Connection
Advanced Search
Member Login Log In | Not a Member? Contact ADC

Technical Q&A QA1295
Java on Intel-based Macintosh Computers

Q: Do I need to change my Java application to run on Intel-based Macintosh computers?

A: The answer is probably no. Pure Java applications require no code changes to run on Intel-based Macintosh computers. This includes the following deployment scenarios:

  • Shell script- or command line-based Java applications

  • Double-clickable jar files

  • Double-clickable Java applications packaged using Xcode, Jar Bundler, or Project Builder

  • Java Applets

  • Java Web Start applications

The story is different for Java applications containing native code. The two cases listed below must be built as universal binaries by following the steps in the Universal Binary Programming Guidelines. These two cases have no exceptions: under no deployment scenarios — not even those listed above — do Java applications that interface with PowerPC-based native code run successfully on Intel-based Macintosh computers.

  • JNI Libraries. JNI libraries built for PowerPC-based Macintosh computers are not loaded under Rosetta because the Java Virtual Machine has already launched without Rosetta. Java applications fail on Intel-based Macs when trying to load PowerPC-only binaries.

  • Native launchers. Native applications that use the VM Invocation Interface to start a Java Virtual Machine must be built as universal binaries to run on Intel-based Macs. The Java VM must run natively; attempts by an application running under Rosetta to instantiate a JVM fail.

It is important to understand that neither of the above cases run under Rosetta because the Java VM itself does not. JNI libraries or native applications which instantiate a JVM must be built as universal binaries to run on Intel-based Macintosh computers.

Only Xcode targets that build native (C/C++/Objective-C) code need to be updated to build universal binaries; Java targets require no changes. If your targets were created with an older version of Xcode, they may need to be updated to native targets. To find out if this is necessary:

  • Open your project in Xcode 2.1

  • Select the target in question (your JNI library target for example) in the Groups & Files list

  • Collapse the Project menu

If the Upgrade to Native Target menu item is enabled, the target must be upgraded before building a universal binary. When the upgrade is complete, a Native Target Upgrade Log appears summarizing any changes. Figure 1 shows an older target that needs to be upgraded.

Figure 1: Upgrading to a Native Target in Xcode.

Figure 1, Upgrading to a Native Target in Xcode.

Once the target is upgraded, it is ready to build a universal binary. See the Building a Universal Binary section of the Universal Binary Programming Guidelines for more information.

Document Revision History

2006-01-10Editorial changes
2005-08-29Image revision
2005-08-25Required changes (if any) for Java applications to run on Intel-based Macintoshes.

Posted: 2006-01-10

Did this document help you?
Yes: Tell us what works for you.

It’s good, but: Report typos, inaccuracies, and so forth.

It wasn’t helpful: Tell us what would have helped.