Java Programming Virgen: I need help!

Discussion in 'Mac Programming' started by bobber205, Nov 15, 2005.

  1. macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #1
    I have used REALbasic for almost two years, so learning Java, although hard, shouldn't be to difficult.

    I figure if I'm going to major in computer software and hardware engineering in college, I should at least get a head start in Java. ;)

    Now here's my question. I got "Ground Up Java" off ebay. Great book. Easy to read.
    But the instructions in it for setting up Java on my mini Mac aren't applying.

    What should I do?
    I can type in Terminal
    "java -version"
    and a bunch of data comes up.

    So I know it's there.
    What should I do? BTW I am planning on using Eclipse or Xcode, and I have installed the developer tools (that's why I have Xcode ;) )

    Thanks.
     
  2. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #2
    Java 1.4.2 is pre-installed with Tiger, and Java 5.0 is available if you sign up as an ADC member (free).

    Download Eclipse (or use Xcode, but I find Eclipse to be easier for pure Java development) and you're good to go, or simply run everything from the command line in Terminal.
     
  3. Retired

    jefhatfield

    Joined:
    Jul 9, 2000
    #3
    don't underestimate java...it's a very deep language and is unlike any other language out there...but you're on the right track if you want to be a software engineer and learn java

    for hardware engineering, that's a completely different field but you may take an electrical engineering class and some higher math if you are software side, and take lots of the above if you are hardware side with some programming, and i hope your school let's you take java if you want to use it for credit towards a computer or electronic/electrical engineering degree
     
  4. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #4
    My school I will be going to, Oregon Institute of Technology, has a special program for people wishing to do the dual-major.

    In Xcode, how can I run the sample programs that came on a CD with my book?

    Here are the files

    Feel free to download them to see what I'm talking about. I want to be able to participate in the "example discussions" that are in my book.

    Thanks! and keep the replies coming!
     
  5. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #5
    Try using the command line first - first thing, write the simplest HelloWorld.java program. The file name must match the name of the class:
    Code:
    public class HelloWorld {
        static public void main(String[] args) {
            System.out.println("Hello World!");
        }
    }
    
    Compile using javac:
    javac HelloWorld.java

    If all goes well, you'll have HelloWorld.class in your directory.

    Run using java:
    java -cp . HelloWorld

    Also, see what happens if you leave out "-cp ." - java won't find HelloWorld.class.

    IDEs like Eclipse take a lot of the work out of your hands, but I really don't recommend using them until you're comfortable with compiling with the command line. You'll make many more mistakes that way, and will learn a lot from them.

    To see the options available for java and javac, type:
    java -help
    javac -help
     
  6. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #6
    BTW If I download Eclipse on my mini Mac 10.4.3 computer, do I need to download all the extra files (like the JDT and stuff like that):D
     
  7. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #7
    This sound really bad, but I guess learning is learning...

    Where do I put and save that code?
    In my book there was a part that had me set up the "path", but I could never do that correctly.

    I have a folder on my Desktop called Java Programming and that's where I want all my files to go. At least I think so.
     
  8. Retired

    jefhatfield

    Joined:
    Jul 9, 2000
    #8
    i had a programming teacher, phd university of oregon in cs in programming languages, but he mainly teaches computer hardware repair (comptia a+ path) at the college, but he had to teach himself that from scratch...he also teaches java and vb, but hardware is his main gig...he's a very unusual person, right and left brained equally, and it makes him understand hardware and engineering, and coding/programming without missing a step

    most programmers just don't get "real" engineering and higher math and vice versa...many a creative writer and artist make better programmers most of the time
     
  9. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #9
    How do I set up the path for my Java programs.
    I need to be able to do that before I can compile don't I?
     
  10. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #10
    Unless I've missed something, it would seem like that file contains no Java source code, merely compiled class files. Did Safari stick the *.java files somewhere I missed?
     
  11. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #11
    All the Java executables (javac, java, etc.) are already in your path, so they should work just fine if you just, say, use Terminal to go to your source directory.

    Or use Eclipse, which works well.

    Or Xcode, which i haven't been too successful using Java with so far...
     
  12. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #12
    Where do I save the text file with the code in it? the .java file/.

    I am EXTREMELY confused. A detailed explanation would be greatly appreciated. I will have to wait awhile, (maybe tomorrow), for Eclipse.

    IT's 100 megs to download... And I have dialup. That's 12 hours or so.

    If someone could explain me how to get properly started, I would be forever grateful.
     
  13. macrumors 6502a

    Joined:
    Feb 17, 2004
    #13
    This little app is a nice way to start off in Java...much simpler than the command line, or even Eclipse. It's basically an editor with a simple front-end for javac and the JVM.

    http://homepage.mac.com/jmacmullin/

    It's not very powerful, but its easy (and free.)
     
  14. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #14
    I"ll use JJEdit until I get Eclipse.

    Thanks so much! BTW Does anybody here use Eclipse for Java for when I need help?
     
  15. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #15
    Have you gone through plinden's post? It's pretty step-by-step.
     
  16. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #16
    I do. Sorry, been a bit busy tonight. I'll try to be of more help later on! Feel free to PM me with any questions.
     
  17. jsw
    Moderator emeritus

    jsw

    Joined:
    Mar 16, 2004
    Location:
    Andover, MA
    #17
    Nope - everything should be all set already under Tiger. BTW, Java 5.0 (aka 1.5) was released via Software Update today... I highly recommend getting it, as 5.0 has some fantastic new features, and you can still use previous Java techniques as well.
     
  18. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #18
    Just thought you guys might want to know!

    I just wrote from scratch my first Java program! YEAH! YEAH!

    The only thing I don't like is each little app costs 6.9 megs of space to build... ???:eek:
     
  19. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #19
    Sorry, haven't been keeping up with this, but WTF? You sure? What program did you compile, using what? HelloWorld.class is 426 bytes on my PC and on my Solaris workstation.

    Can you give us the exact steps one-by-one that you did?

    Even the mail web application I'm working on is only 8 MBytes when compiled.
     
  20. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #20
    I should have given more information.

    I am using XCode right now, and those files include a bunch of "build" files and stuff like that.
     
  21. macrumors 68040

    plinden

    Joined:
    Apr 8, 2004
    #21
    Well, ok, but that's the reason I don't like IDEs - you get a bunch of stuff you know nothing about. If you're serious about Java, you'll have to learn how to set up your build environment yourself.

    Anyway, when you do a release build and hand your programs off to be used, all the build stuff is not (or should not be) included.
     
  22. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #22
    I'm noticing tons of stuff I have no idea what it is.

    If I want to setup the build environment myself, can you point me to a site that explains how to do that from the ground up?
     
  23. thread starter macrumors 68020

    bobber205

    Joined:
    Nov 15, 2005
    Location:
    Oregon
    #23

Share This Page