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.
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.
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...
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!
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 ]
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org