How can I define CLASSPATH variable 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.
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:

echo $CLASSPATH