Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

For a school assignment I need to add a folder to my classpath. It says that I should do this by adding a line to the file .bashrc. However, this file doesn't appear to exist in my computer. I also read something about a file called .profile which doesn't appear either. I found /etc/profile, but it says I have no permission to open it.

Could you please help me? I simply need to add a folder to the classpath.

share|improve this question
up vote 4 down vote accepted

Yes, this file doesn't exist by default. The difference between bash_profile or .bashrc versus .profile is that the latter will be read by shells other than bash. For your purposes, you can simply name it .bashrc. Open up Terminal and enter the following command:

cd ~/; touch .bashrc; open -a TextEdit .bashrc

Now you have a created a profile, which the bash shell will read from everytime you log into it.

Next, simply enter the variable as plain text in the document:

export CLASSPATH=/path/to/folder

Or, if your have a current $CLASSPATH that needs to be added to, append the folder to it in your profile:

export CLASSPATH=$CLASSPATH:/path/to/folder

Save the .bashrc file. Exit Terminal and open Terminal back up (or run . ~/.bashrc in Terminal without exit/reopen).

To test, enter:

share|improve this answer
nice, very nice, teacher :) – Buscar웃 Jul 16 '14 at 7:01
Thank you, I will try it out and accept your answer if it works. :) – Alex Terreaux Jul 16 '14 at 14:06
Thanks for the help. Worked as expected. :) – Alex Terreaux Jul 21 '14 at 19:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.