Xcode interface and Java programming

Discussion in 'Mac Programming' started by fishinatree, Jun 7, 2008.

  1. fishinatree macrumors newbie

    Joined:
    Jun 7, 2008
    Location:
    Santa Rosa, CA
    #1
    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.
     
  2. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #2
    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
     
  3. fishinatree thread starter macrumors newbie

    Joined:
    Jun 7, 2008
    Location:
    Santa Rosa, CA
    #3
    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
     
  4. blakintosh macrumors member

    Joined:
    May 26, 2008
    #4
  5. fishinatree thread starter macrumors newbie

    Joined:
    Jun 7, 2008
    Location:
    Santa Rosa, CA
    #5
    Thanks...I'll check those out. Xcode might be a bit too complicated for me at this point...

    f][sh
     
  6. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #6
    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
     
  7. yeroen macrumors 6502a

    yeroen

    Joined:
    Mar 8, 2007
    Location:
    Cambridge, MA
    #7
    If I developed in Java and wanted to use a cross platform IDE, I'd use Netbeans, no question.
     

Share This Page