View Full Version : about java using xcode

Feb 22, 2009, 09:53 AM
i knew a little c, c++ and objective-c, and a little cocoa.
recently i need to learn java, and i don't know how to use xcode to do some java exercise. which project should i creat? and what's the difference? can i creat a cocoa application and use java?
by the way, can you recommend some books for a absolutely beginner?

Feb 22, 2009, 06:53 PM
Create a Java Tool project. That project template creates a command-line application. A Java programming book that teaches the language would most likely deal with command-line programs.

Alternatively, you could write your Java programs in a text editor and compile them from the command line using the Terminal application.

Apple removed their Cocoa Java project templates in Xcode 3. If you're using Xcode 2, you could create a Cocoa application in Java, but you wouldn't want to because Apple discontinued their support for writing Cocoa programs in Java.

Feb 22, 2009, 10:07 PM
There are dedicated Java IDEs that work on the Mac, e.g. Eclipse. XCode can do Java, but it's not really optimal.

Feb 22, 2009, 11:34 PM
thank you.
what about the new project->java->java application?
and if need the swing?

Feb 23, 2009, 01:25 PM
The Java Application project template uses Swing to create GUI applications. You would need Swing if you want to write GUI applications. If you're starting out with Java and using Xcode, you should begin by using Java Tool projects and learning the language. After learning Java, you can move on to learning Swing.

Feb 23, 2009, 02:49 PM
I think the best Java book for absolute beginners BY FAR is "Head First Java" by Kathy Sierra and Bert Bates, published by O'Reilly. Although this book in its later chapters also covers Swing and other more advanced topics, it does not even want you to use an IDE; the authors recommend that you just stick with a simple text editor and the command prompt instead. Oh, and Kathy Sierra is a Mac user, by the way. ;-)

But if you want to use an IDE for Java, I wouldn't even think about Xcode. The industry standards are Eclipse, Eclipse, Eclipse, Netbeans and IntelliJ. (Somehow, there's an emphasis on Eclipse in that list. How come?)

The Cocoa-Java bridge has been officially deprecated by Apple. It still works (as CyberDuck nicely shows off) but it is no longer under development and it is not recommended to begin new projects with it.

The next release of Eclipse/SWT will be Cocoa-based and you can already download nightly builds of Eclipse 3.5 which work very nicely and even support 64-Bit Java 6 on Leopard.

Although QtJambi has also been officially discontinued a few days ago, at least it has been (or very soon will be) released under an LGPL license to "the community". The latest Qt versions also fully support 64-Bit Cocoa, so Open Source hackers might be very well off with using QtJambi. Just don't expect any commercial support for it.

Swing... I know a very successful multi-platform company here in Bonn, Germany, that although they heavily use Java for their server back-ends, they wouldn't touch Swing with a flagpole. They use SWT for their multi-platform-GUI-needs. But truth be told, only their server administration tool is a GUI-Java application; all other apps are developed natively, meaning they use C# & Windows.Forms on Windows and Objective-C/Cocoa on OS X. But the company's boss told me himself that he and his developers are convinced that Swing sucks. I've heard many other voices saying the very same thing over the last years, and when I see how crappy Netbeans performs on my Mac Pro (especially when compared to Eclipse), I tend to believe them. Eclipse runs great, so it must be the GUI toolkit and Java itself that's the bottleneck.

Feb 24, 2009, 12:28 AM
thank you for giving me a learning path, especially winni's detail.:D