tags:

views:

859

answers:

5

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?

A: 

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)

David Rodríguez - dribeas
The New Project window has changed from 3.0 to 3.2.
mipadi
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.
No longer the case in 3.2.4.
Olie
+1  A: 

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.)

mipadi
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.
David Rodríguez - dribeas
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
(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
That was the ticket. Thanks.
John R Doner
A: 

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

trashgod
+1  A: 
  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

TedCHoward
This solution gives you a java template, but not the accompanying XCode project, which I believe is what was desired.
Olie
A: 

Why not use eclipse ?

kukudas
Actually, as it turned out, I am using NetBeans for Java: by my lights, its a fine IDE. The only thing I don't like in the varioous java IDE's is the layout managers, so I'm writing my own. A good learning-curve project.
John R Doner
Yeah NetBeans should be fine too. I just wondered why xcode? I used xcode myself for a objective-c project and i didn't feel that it is as powerful compared to other IDE's. I could be wrong of course.
kukudas