Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Koreos

macrumors member
Original poster
Mar 4, 2008
56
0
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

macrumors 6502a
Dec 4, 2006
748
0
Katy, Texas
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

macrumors 601
Apr 8, 2004
4,029
142
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

macrumors 6502a
Oct 29, 2006
807
0
Virginia
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

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
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

macrumors member
May 30, 2008
32
0
Eclipse better for Java

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

macrumors member
Feb 20, 2008
87
0
St. Louis, MO
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

macrumors member
Original poster
Mar 4, 2008
56
0
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.
 

moniker

macrumors member
Jun 15, 2007
52
0
London, UK
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

macrumors member
Feb 20, 2008
87
0
St. Louis, MO
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.