This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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 ("") 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...