PDA

View Full Version : Java & C++ in Xcode - Question




Koreos
Feb 1, 2009, 02:35 PM
I know it isn't practical to use Xcode for Java & C++, but I only need it to get by for the school projects (silly, one-file classes). And I would like to avoid having to install different IDEs.

My question is, how do I use Xcode without a project? (using it with a single .java or .cpp file)
I've tried opening the .java file, but all the build, run, debug, etc options are greyed out.

Thank you.



toddburch
Feb 1, 2009, 02:55 PM
The short answer to your question is you don't use Xcode without a project. Create the project sets everything up for compiling and linking and builds.

I created a Java Application project in Xcode the other day, just to see what I would get, and I was very surprised to find tons of crap I did not need.

So, I went back to using an editor (I use TextWrangler) and the command line in Terminal. It works. However, I've gotten myself spoiled on Windows using Eclipse for the last couple weeks. It's like having your own little teaching assistant inside the computer, help you along and pointing out everything you need to know as you go.

I use XCode a lot for C++ projects. It's an all-in-one stop for doc, editing, code completion and interactive debugging.

plinden
Feb 1, 2009, 03:00 PM
Eclipse is also available for the Mac. I also like NetBeans, but I use Eclipse more. Both add a few project-specific files, but nothing that prevents you from using the command line to build and run.

If you use an IDE for Java development, try to spend as much time looking at the file structure of the source code and compiled classes as you do in the IDE itself, so you'll learn about Java itself.

eddietr
Feb 1, 2009, 05:31 PM
If you create a new project using the java command line utility project template, you end up with a pretty clean and useful structure for small learning/teaching exercises.

And you get a basic ant build script that you can also use from the command line.

lazydog
Feb 1, 2009, 06:13 PM
Hi

Xcode is great for C++ and Java (so long as you don't expect a graphical ui builder). For Java it may not have all the bells and whistles as Eclipse or Netbeans but in my opinion it does have a simpler and cleaner interface.

b e n

Cdub16
Feb 2, 2009, 05:33 PM
I write a lot of Java and i just think Eclipse is much easier to use. Eclipse is great and much faster to write code with for JAVA, not objective c. Don't know much about C++. Ive also heard NetBeans is great.

minijon
Feb 4, 2009, 09:20 AM
I find that neither solution is perfect. I use Xcode in the single document per window mode and really like that - its easy to pull information from multiple sources that way.

Eclipse has that one-giant-window school of thought. It's probably less confusing if it's for school projects with a console based main() and a few supporting classes.

The way it reports build errors also seems less confusing.

But because in addition to the crap I'm doing for school, I'm working on iPhone stuff, I find I'm using Xcode for java just because I like the overall interface better.

Koreos
Feb 4, 2009, 03:17 PM
I find that neither solution is perfect. I use Xcode in the single document per window mode and really like that - its easy to pull information from multiple sources that way.

Eclipse has that one-giant-window school of thought. It's probably less confusing if it's for school projects with a console based main() and a few supporting classes.

The way it reports build errors also seems less confusing.

But because in addition to the crap I'm doing for school, I'm working on iPhone stuff, I find I'm using Xcode for java just because I like the overall interface better.

But how do you get Xcode to build, run/debug a single file of java? it's all greyed out for me.

toddburch
Feb 4, 2009, 03:37 PM
You have to go to File -> New Project and pick any of the Java templates.

Dale Cooper
Feb 4, 2009, 03:43 PM
silly, one-file classes

As mentioned, sounds like it would be much less of a hassle to download some plain text editor like Smultron or TextWrangler than messing around with xcode projects...

moniker
Feb 4, 2009, 04:40 PM
But how do you get Xcode to build, run/debug a single file of java? it's all greyed out for me.

You create a new Java project in Xcode, then add that single Java file to the project. Xcode requires a project in order to know how to build and run. Just like most other IDE's.

minijon
Feb 5, 2009, 09:07 AM
Yeah, you've got to start a project. Use the Java Tool thing for the console stuff you start out with. Then to run (and use the console) you have to actually pull up the console window under the Run menu.