aspose file tools*
The moose likes Beginning Java and the fly likes add entry to PATH using Mac OS X Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "add entry to PATH using Mac OS X" Watch "add entry to PATH using Mac OS X" New topic
Author

add entry to PATH using Mac OS X

Mary Kim Harp
Greenhorn

Joined: Apr 11, 2009
Posts: 1
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.

Mary Kim
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

As with any other Unix variant running the bash shell, you set it in your .bash_profile startup file.

The general syntax would be something like:



Be sure to separate each PATH entry with the colon (:) character.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jacob Reisenfern
Greenhorn

Joined: Apr 26, 2009
Posts: 2
This is still above my pay grade

Say I want to set up a folder in my mac documents called "frustration" and I my user name is "trouble" I want all my java stuff to be in there for starters.

Where is the bash startup file,
and would my bash path be "export PATH$PATH":~trouble/documents/frustration ?

Would setting up a file there cause problems for Java finding the other stuff it needs?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Welcome to JavaRanch

Take it easy. No need for the panic.

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
# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

export PATH=.:/usr/java/jdk1.6.0_13/bin/:/usr/java/eclipse/:$PATH
# 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.
Jacob Reisenfern
Greenhorn

Joined: Apr 26, 2009
Posts: 2
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.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40027
    
  28
Well done, Jacob
Mary: Have you got your problem sorted yet?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: add entry to PATH using Mac OS X