I'm trying to learn Java using the Head First Java book and I am already stuck. I believe that there is nothing new to install to use Java on my current operating system (I'm using 10.5.6) but clearly I'm missing something. When I go to compile the "Hello World" program, I get error: cannot read: HelloWorld.java then 1 error on the following line. I am typing the code into Text Wrangler (although I tried using Text Edit first) and I think my problem might have to do with the instruction to "add an entry to your PATH environment variable that points to the /bin directory." I don't really understand how to do this. Although I consider myself pretty Mac literate, this is my first foray into programming. Any suggestions as to what I may be doing wrong would be greatly appreciated.
I only know how you would do it in Linux, never having used OS/X but the two are similar.Find the appropriate file, which using the Gnome desktop and the bash shell, is called .bashrcYou have got the wrong location for PATH. PATH is where you have installed the executable Java™ files. In my case I created a java folder in usr, so my .bashrc file reads
# Source global definitions
if [ -f /etc/bashrc ]; then
# User specific aliases and functions
You can go into your home directory and create folders like thisthen edit the class. You will have to use the real name of your text editor. The & means you can run the text editor and still enter instructions to the shell.
Joined: Apr 26, 2009
The penny finally dropped I think you didn't realize just how far gone I was.
Anyway, you don't need to set path in the mac world. Your java programs can reside in the home directory. When you start up your mac, look at the finder, and you have a home directory under your user name. (I was looking for the string literal usr, where in the case of my computer, usr is Midori. You do your text edit, and save the file to the home folder.
Of course, the next neat thing is, you can move around the folder tree in terminal. If you want to put your java programs in a JavaFolder in your documents folder, that works, but when you sign on to terminal, and you want to play with them, then you have to go cd documents cd JavaFolder to find them the next time you start up the terminal.
Anyway, I found the programs, they ran. Cool.
Joined: Oct 13, 2005
Well done, Jacob
Mary: Have you got your problem sorted yet?