How to set Java Classpath on Windows, Unix, Linux and Mac | Eklavya Online

How to set Java Classpath on Windows, Unix, Linux and Mac

Setting CLASSPATH on Windows XP

  • Right-click My Computer, and then click Properties.
  • Click the Advanced tab.
  • Click Environment variables.
  • Click one the following options, for either a user or a system variable
  • Click New to add a new variable name and value.
  • Enter Variable name as CLASSPATH
  • enter all directories and jar files separated by semicolon. (e.g. c:\dir1;c:\dir2;c:\dir3\abc.jar)

Setting CLASSPATH on Windows 7

  • Click Start
  • Then right-click on Computer,
  • select Properties
  • click Select Advanced System Settings tab.
  • click the Environment Variables button.

Setting CLASSPATH on Unix, Linux and Mac

  • Use export command to set the CLASSPATH environment variable in your system.
  • ExportCLASSPATH=/path/to/dir1:/path/to/dir2:path/to/abc.jar