Not setting the classpath correctly leads a lot of frustration that can be easily avoided.

  • To include a .jar library in a classpath, you have to include the specific filename too. You cannot just include the directory that contains the .jar.
  • It is advisable to have '.', that is, the current directory in the classpath too.
  • Every time you change the classpath, you must open a new terminal (or command window) for the changes to take effect.
  • For Linux systems: my personal .bash_profile file. Every time I want to change the classpath, I edit the classpath variable in it, and run $. ~/.bash_profile for the changes to take effect. Remember the changes take place only in the shell or command window in which it was run.