getting started with java and xcode

Discussion in 'General Mac Discussion' started by abhishekit, Apr 23, 2004.

  1. macrumors 65816

    abhishekit

    Joined:
    Nov 6, 2003
    Location:
    akron , ohio
    #1
    I am trying to get started with java...using xcode..so i m a total beginner to java as well as xcode..can someone please give me simple steps how to compile n run a java program on xcode, as a standalone app..like this
    class HelloWorldApp {
    public static void main(String[] args) {
    System.out.println("Hello World!"); //Display the string.
    }
    }
    when i open xcode, what should i select as new project..if i select java awt app, it makes a bunch of files..keeps indexing lot of .class files...and if i double click on .java file in that list...it already has a whole lot of code..
    so can anyone please help....
    thanks a lot...i wd really appreciate it
     
  2. macrumors 603

    janey

    Joined:
    Dec 20, 2002
    Location:
    sunny los angeles
    #2
    java, javac

    the cli is your best friend :)

    to start with, just use an app like SubEthaEdit, save the file, compile, run, etc. No need to use Xcode when you're just starting ;)
     
  3. Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #3
    You do not want an AWT App (for this case). AWT = Abstract Window Toolkit. If you choose that you are building a cross-platform GUI application so XCode generates a lot of the boiler plate stuff for you. If you want a command line app the choose Java Tool (the last item in the Java templates for me).
     
  4. macrumors 68000

    varmit

    Joined:
    Aug 5, 2003
    #4
    Just choose Java AWT Applet

    But they all do the hello world thing, so you can choose any way of doing Java and the world thing will be in there already. Read their code and see how it works.

    EDIT: Might also want to look into doing it with Cocoa-Java, get the interface of Cocoa and code of Java. It makes making a gui program so easy because you can create the Java code from the interface you create in interface builder.
     
  5. thread starter macrumors 65816

    abhishekit

    Joined:
    Nov 6, 2003
    Location:
    akron , ohio
    #5
    thanks guys...beginning to understand it now..
     
  6. macrumors 65816

    G5orbust

    Joined:
    Jun 14, 2002
    #6
    ARGGH dont use xcode. Its interface is really too slow and convoluted, especially for a basic Java programmer. I suggest trying Netbeans or Jext instead. Much better interfaces, though Netbeans kind of has a PC GUI look to it and accepts only PC functions (i.e.: its control-c to copy, not command/apple-c). Netbeans has some really neat functions, like red underlining of code that is incorrect and finding of braces that dont match up (makes it much easier to run a program knowing the basic problems such as syntax are taken care of precompilation). Jext is very simple and runs fast, though you need to compile from the terminal if you use it.

    I suggest making a single folder for all your code for easy compiling. Put it in your documents folder and every time you need to compile from the terminal type:

    cd /Users/(your user name)/Documents/(folder name)

    Afterwards to compile type:
    javac (file name).java

    And to run the program after compiling:
    java (filename)


    Simple as that.


    public class HelloWorld
    {
    public static void main(String[] args)
    {
    System.out.println("Hello world");
    }
    }
    :)
     
  7. mms
    macrumors 6502a

    Joined:
    Oct 8, 2003
    Location:
    CA
    #7
    Can anyone recommend any good sites for getting started with Java?
     
  8. Moderator emeritus

    Joined:
    Jun 25, 2002
    Location:
    Gone but not forgotten.
    #8
    I would suggest http://www.oreillynet.com/ for most any programming information, including Macintosh-specific issues. You can also go to http://java.sun.com.
     

Share This Page