Results 1 to 9 of 9
  1. #1
    java beginner is offline Member
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default Java Programming on a Mac? Please help steer me in the right direction

    Hello,

    I'm brand new here. This forum looks awesome!

    I just bought a MacBook Pro with OS 10.6.7 "Snow Leopard".

    My goal was to install IntelliJ as the IDE and the Java 1.6 SE from Oracle as the JDK.

    However, when I went to the Oracle site, I only saw JDKs for Windows, Unix, and Solaris.

    Where do I get the Java 1.6 SE JDK for Mac?

    I'm open to different ideas. I heard of things called Eclipse and NetBeans as well. So if Netbeans or Eclipse has some sort of "giant enchilada" install where it will put the Mac version of the JDK and the IDE on the computer all in one shot, that could be really cool.

    I bought a 1000 page book on Java. But the hardest thing for me right now is actually installing the Java stuff on the computer and getting that stuff to work so I understand my way around.

    The Apple website says if you buy the latest Snow Leopard Mac operating system it comes with some sort of Java JDK "in the box". But that sounds like it's for people who have an earlier version of OSX, and are looking to upgrade to the latest Mac OS. The Apple website does not say if my brand new computer has this JDK installed. It also uses vague language. It does not say who the vendor is for this JDK, and does not say if it is 1.6SE or something different.

    I'm looking for a simple set of instructions like "do this, do that" and then all the Java development stuff I need will be installed on my new computer.

    I'm brand new at this, so I'm looking for the free community-type stuff rather than the paid $600 stuff. It will be a *long* time before I'm advanced enough to use the elaborate expensive stuff anyway.

    I'm a very hard worker. I just don't know which way to run on this.

    Thanks for any insights, and I'm glad I found this forum.
    Last edited by java beginner; 05-02-2011 at 12:06 AM.

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    You can test to see if you have a compiler by opening terminal(or whatever the Mac equivalent is) and typing javac, tell me what it says.

  3. #3
    java beginner is offline Member
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Thanks,

    I stumbled my way into finding a command line of some sort by going to Applications>>Utilities>>Terminal. But when I type javac, it just prints a lot of meaningless stuff to the screen.



    However, I did manage to find a promising file area:

    Macintosh HD/System/Library/Java/JavaVirtualMachines/1.6.0.jdk


    I clicked on the file that says 1.6.0.jdk.

    It then launched a small window with Java Preferences stuff that I didn't understand so I left it alone. Some of the checkbox stuff said Java SE 1.6 on it. But it was in the context of "preferences". It did not outright say "You have Java SE 1.6 installed on your computer". It said "Java applications, applets, and command line tools use this order to determine the first compatible version to use":
    Java SE 6 Vendor: Apple Inc. 64-bit
    Java SE 6 Vendor: Apple Inc. 32-bit

    It then asked if you wanted to change the order, so an application would look for the 32-bit version first instead of the 64-bit. It doesn't say the computer actually has either one of these Java SE 6. It just asks which order you want an application to try to use them. Theoretically, my computer could have *neither* of these versions installed. In this case, the computer is asking a purely hypothetical preference question for applications that aren't actually installed.

    There are so many new things to me like a "Java Virtual Machine" a "runtime environment" and a "JDK". I'm starting to see the word javac mentioned. I'm guessing this has something to do with the compiler... like Java-Compiler...Java-C....javac. It's like I'm on an Easter Egg hunt to see if I have all the correct stuff installed on the machine. The problem is I'm not sure what all the eggs are I'm supposed to have on the system, where to look for them, or what they are called. Total guesswork.

    I wish there was some sort of checklist, like:

    Make sure you have these installed:
    1)
    2)
    3)

    You find out if they are installed by doing:
    1)
    2)
    3)

    You download any missing components from:
    1)
    2)
    3)
    Last edited by java beginner; 05-02-2011 at 12:58 AM.

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    haha, just try what I suggested and let me know what it spits out. Open terminal(or whatever the mac equivalent of command prompt is) and type javac, copy/paste what it spits out and I'll be able to tell you if you have a compiler and then I can also help you compile and run your first program if you'd like.

  5. #5
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default

    The JDK by default is installed on mac OSX. As it seems you've most likely found you can access it using the terminal (I presume but without knowing what it prints when you try the command can't be sure - I'm betting what you've seen it print out are instructions for using the tool on the command line). If you type in the terminal 'java -version' it will print the version you have (in other words it's installed) - you must feed the instructions and files for it to do anything constructive. To do so, write your .java file, 'cd' into that directory and type 'javac myfile.java' and it should create a .class file which you can run using the java command: 'java myclass'. My bet is you are unfamiliar with the terminal, in which case you should read up on how to use it - google something like 'unix command line tutorial' to find instructions if you don't know how to use it.

  6. #6
    Join Date
    Apr 2011
    Posts
    7
    Rep Power
    0

    Default eclipse

    I have a macbook pro and I use eclipse, its a great java IDE, I have never used anything other than eclipse for java, but thats because I have liked using eclipse.

  7. #7
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    As doWhile said, the exact return of javac can be helpful, but it looks like you have the compiler and it gave you instructions. Here is a step by step to create, compile, and run a simple program.

    1.) open a text editor and save a file called HelloWorld.java
    2.) Type in the following
    Java Code:
    public class HelloWorld{
      public static void main(String[] args){
        System.out.println("Hello, it's working now, it's working");
      }
    }
    3.)Open your terminal cd(or whatever the mac command is) to the directory where you saved the HelloWorld.java file
    4.)type javac -cp . HelloWorld.java
    5.) type java HelloWorld

    If everything was successful, you should see the text: "Hello, it's working now, it's working"


    If this happens you are ready to start reading your book. While IDE's are very helpful, I'd like to suggest you use a simple text editor(like notepad++) and use terminal and notepad++ to compile and run your programs. This will get you comfortable with navigating through the file system via the terminal. It will also get your to learn some things that IDE's auto generate(thus making you learn more imo)


    As a random side note: What book have you purchased?

    Since you are new, I would like you to post a link to my blog(which I don't post on very often, however; I recently made a post so I don't repeat book recommendations constantly) feel free to check it out, I listed a few java books, c++ , books and then a few other books as well, here is the link

    My book suggestions
    Last edited by sunde887; 05-02-2011 at 03:25 AM.

  8. #8
    java beginner is offline Member
    Join Date
    May 2011
    Posts
    9
    Rep Power
    0

    Default

    Here's what the Mac echoes to the screen when I type javac into the Terminal prompt area (be careful...it's weird!):

    Usage: javac <options> <source files> where possible options include: -g Generate all debugging info -g:none Generate no debugging info -g:{lines,vars,source} Generate only some debugging info -nowarn Generate no warnings -verbose Output messages about what the compiler is doing -deprecation Output source locations where deprecated APIs are used -classpath <path> Specify where to find user class files and annotation processors -cp <path> Specify where to find user class files and annotation processors -sourcepath <path> Specify where to find input source files -bootclasspath <path> Override location of bootstrap class files -extdirs <dirs> Override location of installed extensions -endorseddirs <dirs> Override location of endorsed standards path -proc:{none,only} Control whether annotation processing and/or compilation is done. -processor <class1>[,<class2>,<class3>...]Names of the annotation processors to run; bypasses default discovery process -processorpath <path> Specify where to find annotation processors -d <directory> Specify where to place generated class files -s <directory> Specify where to place generated source files -implicit:{none,class} Specify whether or not to generate class files for implicitly referenced files -encoding <encoding> Specify character encoding used by source files -source <release> Provide source compatibility with specified release -target <release> Generate class files for specific VM version -version Version information -help Print a synopsis of standard options -Akey[=value] Options to pass to annotation processors -X Print a synopsis of nonstandard options -J<flag> Pass <flag> directly to the runtime system



    I have no idea what all of that is. I was hoping it would say something like "You are using Java SE version 1.6 JDK for the Mac. You are ready to start programming, compiling, and running applications in Java on this machine".

    When you click on the little apple picture at the top of the Mac OS screen, it tells you what version of the operating system you are using. So I was hoping it would do the same thing.

    The book I got is Introduction to Java Programming, comprehensive version. The author is Liang. It talks very briefly about Eclipse, and then says refer to Supplement II for more information. But I can't find anything called "Supplement II" in the book.

    The book is over 1000 pages. It looks like a good book, but the author could have spent 20 pages in the front on setting up environments and downloading JDK kits and stuff. The beginning pages have some somewhat silly topics like "What is a computer?". I would have much preferred a point-by-point expose on installation, configuration and basic usage if the major Java IDE's such as Eclipse, Netbeans, and IntelliJ. And perhaps some of the author's personal opinions on which one he likes best and why. That would have been sweeeeeet!

    I'm sure this is a "real" book to learn "real" Java programming. But right now I'm "real lost" on setting up the actual programming environment. LOL.:)


    Thanks for all the help so far. This looks like a great forum, and I can tell you guys are trying to help me get unstuck from the mysteries of how to get up and running with Java/IDE/Mac.
    Last edited by java beginner; 05-02-2011 at 05:01 AM.

  9. #9
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Don't worry, I consider myself fairly experience with java and I still get pretty confused with the set up stuff. I normally link people to a great video tutorial, unfortunately it's a windows based installation.

    When you type javac it looks like it is giving you instructions, so you may alread have everything you need. I would like to again suggest you don't use an ide right away. IDE's are supposed to be awesome(I don't use one atm), but they have a lot of auto generated, and auto completion stuff; it may be beneficial to learn what packages contain which classes in the standard libraries. There are also other useful things that learning through terminal and notepad(or notepad++, my favorite atm) will provide.

    Did you try doing my step by step above? If so, what happened?

    I have never heard of the book you are reading; let me know what you think of it. If you would like some other suggestions as well; here is a blog post of mine that I created to save myself time(it's quicker to create a blog post and link to it, then write a very lengthy post everyone asks for book suggestions): My book suggestions

    My favorite for beginners is Head First Java. If you end up enjoying your book, great; but if you feel having another book would help, consider Head first java, or the others I mentioned. Having multiple books will definitely help you. I am reading 3 atm, about to get 2 more(one that I am especially excited for), and I have 3 that I am about half finished with that I need to get back to. It's nice to see different authors approach to similar topics.


    Get back to me on if the step by step compiling and running of a simple hello world program worked.

Similar Threads

  1. I need a little direction for a dictionary app
    By Alexis in forum AWT / Swing
    Replies: 5
    Last Post: 02-11-2011, 07:43 PM
  2. random direction
    By i8java in forum Threads and Synchronization
    Replies: 5
    Last Post: 04-26-2010, 10:37 PM
  3. Looking for direction...
    By ewomack in forum New To Java
    Replies: 4
    Last Post: 09-13-2009, 11:00 PM
  4. [SOLVED] Need direction...
    By hotice1027 in forum New To Java
    Replies: 5
    Last Post: 11-28-2008, 09:03 AM
  5. I need direction too. output control
    By bornwithnoname in forum New To Java
    Replies: 0
    Last Post: 11-23-2008, 03:57 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •