Setting the class path

This tutorial offers step-by-step instructions on how to set up the class path. I will use selenium-java-client-driver.jar and junit-4.5.jar as examples to show you how to add them to the CLASSPATH.

  1. Depending on the version of your MS Windows, the steps below may be different but similar.
    • If you are using MS Windows XP, then open [Classic View]Control Panel->System->Advanced->Environment Variables.
    • If you are using MS Windows Vista, then open [Classic View] Control Panel->System->Advanced system settings->Advanced->Environment Variables.
  2. Under the User variables for X(e.g. Administrator) section, search for the CLASSPATH variable. If the CLASSPATH variable is not listed, then create it. Otherwise, edit it.
  3. If you have to edit it, then select it. Click on the Edit button and append the following line to the Variable value input field:
    ;C:\selenium-java-client-driver.jar
     
    Note: There is a semicolon(;) in front and the path may be different in your case depending on the location of your selenium-java-client-driver.jar file. The semicolon(;) is used to separated multiple paths. For example, if you want to also add JUnit's jar file to the CLASSPATH, you have to append the following line to the Variable value input field:
    ;C:\selenium-java-client-driver.jar;C:\junit-4.5.jar
     
  4. If you have to create it, then click on the New button. Set the Variable name to CLASSPATH and then set the Variable value to
    C:\selenium-java-client-driver.jar
     
    Note: To add multiple paths, use the semicolon(;) as separator. For example, if you want to also add JUnit's jar file to the CLASSPATH, then set the Variable value input field to
    C:\selenium-java-client-driver.jar;C:\junit-4.5.jar  
     
  5. Click on the OK buttons.
  6. Open a new Command Prompt for the change to take effect and then execute the following command:
    echo %CLASSPATH%
     
    It should return the paths of your jar files(i.e. paths of selenium-java-client-driver.jar and junit-4.5.jar).