7

I am currently programming Objective-C in the Xcode IDE, and I understand it should also support Java projects. When I open the IDE and choose New Project, I don't find any project templates that correspond to Java. I have Snow Leopard, so I assume my Xcode is up-to-date.

How do I start a Java project in the Xcode IDE?

4 Answers 4

4

I think what you want is a "JNI Library" project, which has the description "This project builds a Java JNI library with a bundled application wrapper." In Xcode 3.2, this project template can be found under Mac OS X > Framework & Library > JNI Library.

(Edit: This is what Apple officially recommends, too. See this document.)

4
  • Are you sure? Java Native Interface is a library to interface from java an native code, so I am not sure this would be the option to create a plain Java project. Jan 9, 2010 at 22:20
  • I'm not sure. I don't work with Java + Cocoa a whole lot. However, as the description states, it does contain stubs for creating a Java application, as well as stubs for the configuration options needed to create a Mac OS X Java-based application.
    – mipadi
    Jan 9, 2010 at 22:26
  • (Any Java-based Mac OS X app that wants to use the Cocoa framework is going to have to use JNI in some way.)
    – mipadi
    Jan 9, 2010 at 22:27
  • That was the ticket. Thanks. Jan 10, 2010 at 5:21
3
  1. Open Xcode 3.2.
  2. Show the Organizer window (Window->Organizer).
  3. Click the '+' button in the lower left corner of the Organizer window.
  4. Choose "New From Template"->"Java Templates"->"Java Application"

Xcode relies on Ant to build Java projects, so you can edit your code in the organizer window or use whatever IDE or editor you wish. Then just open a terminal window, change to the folder's project, and execute ant.

http://developer.apple.com/mac/library/documentation/Java/Conceptual/Java14Development/02-JavaDevTools/JavaDevTools.html

1
  • This solution gives you a java template, but not the accompanying XCode project, which I believe is what was desired.
    – Olie
    Oct 4, 2010 at 4:53
0

For reference, you'll find several example projects in /Developer/Examples/Java.

-1

Fire up Xcode, select new project, scroll down until you see Java and select the type of project... not that hard (at least with Xcode 3.0)

2
  • The New Project window has changed from 3.0 to 3.2.
    – mipadi
    Jan 9, 2010 at 20:50
  • I'm running 3.1.2 and its pretty much as straight forward as possible. You have main categories and Java is one of them. Just select that and you have your various templates.
    – alphazero
    Jan 10, 2010 at 0:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.