• 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

add entry to PATH using Mac OS X

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
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
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.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well done, Jacob
Mary: Have you got your problem sorted yet?
 
reply
    Bookmark Topic Watch Topic
  • New Topic