Super Basic Java Help?

Discussion in 'Mac Programming' started by stehfee, Feb 11, 2011.

  1. stehfee macrumors newbie

    Joined:
    Feb 11, 2011
    Location:
    NY
    #1
    Okay, so I'm taking a Java course this semester cause for whatever reason, it's required as part of my major requirement (Math Ed.) The prerequisite was Visual Basic, which I took last semester and got an A. So I'm not necessarily stupid, but I DO need to be taught in order to do well. I don't have ANY background knowledge whatsoever.

    Okay so here's the thing, in my class, we have Windows desktop computers that we use. We code the Java applications using notepad and save them as a .java file. Then we open up the command prompt, type in 'F:' to get to our USB drives, then type in 'javac FirstProgram.java' to compile our program. Then to run it we type 'java FirstProgram'.

    Now here's my issue. I have a Macbook (clearly, hence my presence in this forum). Yet, I would like to do some of my work at home. Last semester sucked having to stay in the school library for various lengths at a time to use Windows for Visual Basic. Plus, these library computers for some reason can't compile the code. =(

    Oh, and I don't want to partition my hard drive or anything like that so I can get Windows running cause I won't need it after this semester.

    SO how would I do the equivalent of all of that on a Mac? Are there applications already included, or do I have to download something? And if I DO have to download something, what would it be, and is there a free version of it?

    Thanks in advance to anyone who helps me. I'd REALLY appreciate it! =D

    :apple:
     
  2. McGordon macrumors member

    Joined:
    Dec 28, 2010
    Location:
    Scotland
    #2
    Your Mac already has everything you need to do that. You'll find a command prompt in the Terminal application in /Applications/Utilities. (The Utilities folder which is inside the Applications folder). Then you're good to go:

    cd /Volumes/Your_USB_Drive
    javac FirstProgram.java
    java FirstProgram
     
  3. stehfee thread starter macrumors newbie

    Joined:
    Feb 11, 2011
    Location:
    NY
    #3
    Thank you so much! So I need to type in exactly that? Like I knew about Terminal but I wasn't sure if it already had those capabilities. I also couldn't figure out how to navigate through different drives. xD
     
  4. wrldwzrd89, Feb 12, 2011
    Last edited: Feb 12, 2011

    wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #4
    If your USB Drive name has spaces in it, they'll need to be escaped with backslashes. Fortunately, the Terminal will do this for you if you type cd, then a space, then drag the USB drive's icon into the Terminal window.
     
  5. stehfee thread starter macrumors newbie

    Joined:
    Feb 11, 2011
    Location:
    NY
    #5
    Okay, I haven't tried that yet cause my USB drive is temporarily misplaced. But I have the code (I typed it into a facebook message earlier so I could copy and paste it). What would I paste the code into? I just tried pasting it into TextEdit and saving it as CandyShop.java, but it says it has to be saved as a .rtf file. So now what?

    I'm sorry this seems so elementary. I'm really not super computer illiterate, I swear. xD
     
  6. wrldwzrd89 macrumors G5

    wrldwzrd89

    Joined:
    Jun 6, 2003
    Location:
    Solon, OH
    #6
    You have to convert to plain text in TextEdit first, in order to save files that the Java compiler understands. To do that... choose "Make Plain Text" from TextEdit's Format menu.
     
  7. stehfee thread starter macrumors newbie

    Joined:
    Feb 11, 2011
    Location:
    NY
    #7
    Oh, wow. I forgot TextEdit isn't plain text. xD THANK YOU SO MUCH! It works now. ^_^ I mean, my program doesn't work cause it hates me, but at least I can figure out my homework on my laptop. Thank you thank you thank youuu! :D
     
  8. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #8
    You might want to pick up a free programmer's editor like TextWrangler or Fraise. Or buy one like Smultron. (Or go IDE and pick up something like Eclipse).

    B
     

Share This Page