How to Create Java Projects With Xcode

By Michael Dominick

Mac OS X and iOS developers are intimately familiar with Apple's Xcode development environment. Xcode is a full-feature tool that helps software developers produce rich applications for Mac OS X and iOS. Developers for iOS and OS X traditionally develop their applications using the Objective-C and Cocoa (Cocoa Touch for iOS) application framework. However, some software engineers prefer to work with alternative software development tools. One popular choice is Java. Knowing this, Apple has made developing Java-based applications easy using Xcode.

Things You'll Need

  • Xcode
  • Java
  • JDK

Step 1

Verify that Java is installed on your system. To do this, open a terminal and type the following command: Java -version. Mac OS X comes pre-installed with the Java runtime environment and its corresponding Java developer kit (JDK), so you should see a version of Java printed out in the terminal. As of June 2011 the current version of Java for Mac OS X is Java 1.6, so if you see a lower version number printed out in your terminal, then you need to update your system's software via the built-in software update tool.

Step 2

Open Xcode and create a new project based on the empty template under the OS X tab. Users familiar with out-of-date versions of Xcode (the current version of Xcode as of June 2011 is Xcode 4) might remember that there used to be templates dedicated to different types of Java applications, but this is no longer the case. You will be presented with a completely bare Xcode project.

Step 3

Create the Java main file for your application by selecting "New File" from the file menu and naming the file "Main" with the ".java" extension; all Java applications must have a main file.

Step 4

Right-click on the left pane of the IDE and select the "Add Group" option. This will create a folder with a name of your own choosing within the project, allowing you to organize your Xcode project in a logical manner.

Step 5

Begin writing the code for your application. Assuming there is nothing wrong with your Xcode installation or your Java installation, Xcode should automatically provide syntax highlighting for your Java code.

Tips & Warnings

  • Though Java was once well supported in Xcode, its support lags behind the support of other languages, particularly Objective-C, C, and C++. For example, you may find that the syntax highlighting for Java is not as complete as it is for those languages or as specific as it is in IDEs for Java.