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

fishinatree

macrumors newbie
Original poster
Jun 7, 2008
15
0
Santa Rosa, CA
I'm new here: brand new to the forums and to the world of Java programming and Xcode, and I have some questions that have not been answered by countless searches on developer.apple.com or google:

Evidently Xcode includes a JDK and JRE, but I don't know how to use either.

How do I compile/run a short, simple program like the classic "Hello, world!" one? I have the code written in a text editor, but I don't know how to use Xcode with it.

Thanks!

Edit: I'm running 10.5.2 with Java upgraded to 1.6 on a 2.2 Ghz Macbook.
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Still on XCode 2.3 on OS 10.4 here, but hopefully this is similar enough...

File->New Project...->Java section->Java Tool

The default project has a Hello, World! example in the static void main, so that should be enough to get you started.

I can't speak to setting which JDK and JVM to build against/target/etc. so someone else might have to help you out there, as I'm not sure even when you get 1.6 installed that that is the target in XCode.

-Lee
 

fishinatree

macrumors newbie
Original poster
Jun 7, 2008
15
0
Santa Rosa, CA
Thanks, but I still don't really know what's going on here. Any link to a very VERY basic tutorial for Xcode and Java would be useful.

f][sh
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
Don't call system.exit() in your program if you are working in BlueJ. It runs your program in the same VM as the IDE as a thread, so if you do the editor closes, too.

There are lots of options...
IntelliJ <Just saw this is not free, so I wouldn't consider it>
NetBeans http://www.netbeans.org/
Eclipse http://www.eclipse.org/

XCode is great, but is not cross platform. If you are using Linux at some point in the future, or Windows, you won't have XCode available, but the other IDEs mentioned will be.

If you don't already, you should learn how to compile with javac, run with java, create executable jars with jar, run them with java -jar, etc. Unlike some other things, I wouldn't discourage the use of an IDE unilaterally for Java because of the breadth of the class library, but don't let the IDE be a substitute for knowing how to do things, use it as a tool for speeding up things you could do yourself.

-Lee
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.