1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Java Programming: Beginning

Discussion in 'Mac Programming' started by iEdd, Dec 26, 2005.

  1. macrumors 68000


    Hey all, I got a book called Beginning programming with java for dummies by Barry Burd for Christmas. I read a bit through and I wanted to know what you guys recommend as an IDE or JDK (I think I have the terminology correct). I am currently using Netbeans, but I am aware that there are others like xcode, jbuilder, etc. I also have Java 2, build 5.0 version 3 I think it's called, the one up from version 1.4.2_09 or something. What an intelligent bunch that designed these version numbers :rolleyes:
    So my questions are:
    •What development software is best for a n00b like me?
    •Does anyone else have this book?
    •Any other good starting points you can recommend?
  2. macrumors 65816


    Eclipse is the dominant free IDE. It's where you'll want to end up if you're serious about Java, but it has it's own learning curve...

    There's a free IDE supposedly for beginners called BlueJ. Gosling wrote positive things about it some time ago.

    I'm no longer sure what the best Java book for beginners is. I've heard lots of good things about Head First Java - but I've not read that one myself. Once you lose your training wheels then Effective Java by Bloch is the bomb.

    BTW, I'd add that if you are wanting to do Mac development then Objective-C and Cocoa is where you want to be. If you need cross platform, then Java rules.
  3. Moderator


    Staff Member

    For a complete newbie I would recommend just using your favorite text editor, something like TextWrangler or SubEthaEdit and then make small non GUI test programs that you compile and run with Terminal app. (javac/java). That's the best way to learn the basics.

    Then when you need your first IDE, get BlueJ, it's made to be educational (wish that had been around when I started learning Java ;)).

    Then, when you grow out of that, go for Eclipse. :)
  4. macrumors 68000


    Thanks for the comments and tips guys. I have been mucking around with ultra simple small programs in BlueJ, but I don't know how to run the .java file, all I get is the "There is no default application specified to run this document" dialog box in the finder.
    Just making use of the
    command with a few words. Excuse the lack of programming intelligence. *shrugs*
  5. Moderator


    Staff Member

    To start with the very beginning, the "hello world" app:

    Use your favorite text editor and make a file named HelloWorld.java (mind the capital letters, HelloWorld is not the same as helloworld!), and enter this code:

    class HelloWorld {
        public static void main(String[] args) {
            //Display "Hello World!"
            System.out.println("Hello World!");
    Open up Terminal.app, and navigate to where you saved the java file:

    $ cd /path/to/file/

    Then you must compile:

    $ javac HelloWorld.java

    And then you can run the application:

    $ java HelloWorld

    This will give you this output:

    $ Hello World!

    Then it's just a matter of adding more code into the main() method and start making your own functions and classes... ;)

    If you've made a similar file in BlueJ, compiled that and then want to run it, you need to right/ctrl-click on the class in the project window and mark the method you want to run (in this case the main() method) as stated in the BlueJ tutorial:

    Attached Files:

  6. macrumors 6502a


    NetBeans is very good. If you are comfortable with it, I'd suggest sticking with it. If you start to find it lacking or it doesn't seem to fit your work style, try Eclipse. Personally I prefer NetBeans and you'll find that everyone has an opinion on which has the greater market share and which is better. Yes, Java has its own IDE religion war!

    * Get hold of the Java Certification Study Guide (get the latest version you can find)
    * Go to java.sun.com and try the tutorials (there are masses there)
    * Both java.net and onjava.com have excellent and regular articles on Java technologies
    * Later (after you have been coding for six months or so), check out:
    ** "Effective Java" / Bloch; Addison Wesley Press
    ** Junit (a simple technology to build unit test cases)
    ** Apache Ant (a simple Java-based build tool)
  7. macrumors 68020


    I would have to highly recommend "Thinking In Java".

    It's a great book, and it's REALLY cheap on ebay.:D
  8. macrumors 6502

  9. macrumors 68020


    But I've always liked a hard copy of really useful information.
  10. macrumors 6502

    oh, definitely, a hard copy is better. But it's a good way to take the book out for a test run.

  11. macrumors 68020


    I learned Java from the command line, then upgraded to JBuilder (at work) and Eclipse (at home/school).
  12. macrumors 603


    This is usually what I try to recommend to beginners too. No reason to introduce an IDE when you are just learning the language, it only provides another point of confusion. FWIW, I start out with command line, Visual Cafe, Eclipse 2, WSAD, Eclipse 3, and most currently Rational Application Developer.
  13. macrumors 68000


    Thanks for all the further replies. I'm not sure how writing java in a command line makes things easier. I rarely have success with terminal, all these errors occur. BlueJ has made things easy for starting. Basicly just 4 steps:
    •Start new class
    •Type code
    It's all good. Once again, MR always brings good replies fast. Thanks heaps.
  14. macrumors 603


    Because you will learn the ins and outs of the SDK and the JVM. ;)
  15. macrumors 65816


    nicely done. Good for you.

  16. macrumors 68020


    Do you want simplicity or do you want an understanding?

    Writing and compiling from the command line gives you a more complete understanding of the process(es) involved in Java development. Using an IDE to do things like package management abstracts a lot of the critical pieces of the language that are best learned, at first, from the command line.

Share This Page