• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MAC OS X Set-Up

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, two right-at-the-beginning questions:

1) Where do I save my .java files on the latest version of OS X?

2) How do I make sure Terminal is pointing at the right folder? At the moment, when I run "%javac myprogram.java", I get "no such job".

I've done absolutely no set-up as the book tells me it's not needed on OS X. My Unix skills are very low, so a pointer to a good beginner's site would also be appreciated.

Thanks for your time,
Simon.
 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1) Wherever you want. I usually set up a project folder in my user area and work on my projects there.

2) Are you familiar at all with a unix command line? If not, you'll need to bone up on the bash shell.

The cd command changes your working directory (folder) and pwd shows you what it is.
 
Simon Dean
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Bear.

So if I can use any folder, how to I point the JVM to that folder so that it will find my progs?
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's what the "current working directory" is all about. And of course, the classpath.

Have you done any command line Java work anywhere?
[ March 03, 2008: Message edited by: Bear Bibeault ]
 
Simon Dean
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Nothing. Started out yesterday. )

I did do some C++ about 10 years ago, so I should be able to pick stuff up relatively quickly.
 
Simon Dean
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, that smiley was not meant to be like that!

If you like Sci-Fi, Bear - try Iain M. Banks, if you haven't already.
 
Simon Dean
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I've read up on the sourcepath and the classpath and sorted everything out. Everything's hunky dory now and I've just compiled my first .class

Many thanks for your input, Bear. Much appreciated.
 
Bear Bibeault
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very cool. Any unix command line reference should be fine for you to look at.

Windows, not so much.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Simon Dean:
2) How do I make sure Terminal is pointing at the right folder? At the moment, when I run "%javac myprogram.java", I get "no such job".

You should not be typing the "%" symbol at the start of the line. As Bear suggests, you will need to learn a bit about whatever unix shell you are using (typically Bash under OSX). Perhaps look for a tutorial on Bash on the internet to start with.

A little more information (which may be too much information for where you are right now - you decided for yourself) ...

Unix has the ability to run any job (process / application) in the foreground (where you get to see it, or the background. For example, from the command line, I could issue a command such as:
This will run in the foreground - that is, it while it is running, I cannot do anything else at that command prompt. You could, of course, open up multiple windows to run your various jobs in, but we also have the ability to put these programs into the background.

I have 2 options here:
  • I can type "Ctrl-Z" (which will suspend the running job), then type "bg" to put it into the background.
  • I can explicitly state at the time I start the job by putting an ampersand ("&") at the end of the line. Here are examples of the two in practice:

  • In the first instance I used the invisible "Ctrl-Z" to suspend the job (hence the "zsh: suspended" line) then put the job into the background, at which point it told me that job 1 ("[1]") has been "continued".

    In the second instance the job was immediately put into the background because I had an ampersand ("&") at the end of my line. I was told that this is now job number 5 and I was told it's process identification number (PID): 31298.

    NOTE: I did not type the "~%" in either of those cases - they are the prompts that let me know when I am supposed to start typing. If you are using Bash then your prompt may be a dollar sign ("$"). Another system I am running on has the prompt set to:

    Where it starts with the computer I am on, then tells me what directory I am in (the "~/src" where "~" is my home directory), then tells me who I am logged in as ("andrew") followed by a dollar sign.

    Anyway, back to my never ending saga. I put 2 jobs into the background. Let's prove it:

    So they both exist, and will both keep running forever (or until the computer stops - probably the second option ).

    If I want to bring either job back to the foreground so I can then interact with it again (or just kill it), I can use either the "fg" command (for foreground) or the "%" command (for those people who think that "fg" is too many characters ):

    In the first instance I told the system to bring to the foreground the most recent job that started with "while" (kind of silly since both jobs started with "while" - I could have just used "fg" on its own for the same effect).

    In the second instance I told the system to bring to the foreground job number 1.

    So when you typed "%java", the system thought you were trying to tell it to bring to the foreground some job that started with the command "java". And it was unable to find this job.

    Regards, Andrew
     
    Simon Dean
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Many thanks, Andrew! Useful stuff.

    You know, I was thinking, Why is he telling me all this stuff NOW? It all became clear at the end. I feel like a right idiot that I didn't understand that the % in the Head First book was just the command prompt. But I bet I'm not the first or last to make that mistake...

    Thanks again for your time,
    Simon.
     
    Bear Bibeault
    Sheriff
    Posts: 67747
    173
    Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    LOL, it never occurred to me that you were actually typing the %. I just thought you were using it to indicate typing at the prompt that same way that most books do!
     
    Sheriff
    Posts: 11343
    Mac Safari Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    If you're looking for a good book (as I was when I switched to Mac), try The Mac OS X Command Line: Unix Under the Hood by Kirk McElhearn.
    [ March 03, 2008: Message edited by: marc weber ]
     
    Sheriff
    Posts: 4012
    6
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    A handy online reference is sometimes nice too. Have fun with Terminal, java and Head First.
     
    marc weber
    Sheriff
    Posts: 11343
    Mac Safari Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Originally posted by Pauline McNamara:
    A handy online reference is sometimes nice too...


    Wow, that's a good one! Thanks for posting.
     
    Simon Dean
    Greenhorn
    Posts: 7
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Many thanks to all of you for the extra tips!
     
    Are you okay? You look a little big. Maybe this tiny ad will help:
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic