# Setting the environment variables

There are several environment variables that must be set depending on the method that you selected to run the Derby tools and startup utilities.

As mentioned in choosing a method to run the Derby tools and startup utilities, you must set the DERBY_HOME environment variable so that you can use the command examples that are presented in this manual. Adding the Derby scripts directory to your command execution PATH makes the scripts easier to use and enables you to use the script examples in this manual. The CLASSPATH environment variable must be set if you are using Derby in a Java program or executing the tools using the `java` command.
The steps below show you how to set the environment variables in a command window. The settings are only valid for that window. If you close the command window or open a new command window, you must set the environment variables again.
Tip: You can also set environment variables permanently. For example, on Windows you can use the Control Panel to permanently set the environment variables.

To set the environment variables:

1. Set the DERBY_HOME environment variable to the location where you extracted the Derby bin distribution. For example, if you installed Derby in the `/opt/Derby_10` directory on UNIX or in the `c:\Derby_10` directory on Windows, use the following command to set the DERBY_HOME environment variable:

   Operating System | Command
   --- | ---
   UNIX | `export DERBY_HOME=/opt/Derby_10`
   Windows | `set DERBY_HOME=c:\Derby_10`.

2. Be certain that the `java.exe` file, version 1.4.2 or, higher is in your command execution PATH. Open a command window and run the `java -version` command.
3. Add the `DERBY_HOME/bin` directory to the PATH environment variable so that you can run the Derby scripts from any directory.

   Operating System | Command
   --- | ---
   UNIX | `export PATH="$DERBY_HOME/bin:$PATH"`
   Windows | `set PATH=%DERBY_HOME%\bin;%PATH%`. If you use the Control Panel to update your system PATH, add `%DERBY_HOME%\bin` to the end of the PATH environment variable

   Tip: When the DERBY_HOME environment variable is set and the underlying `/bin` directory is included in the PATH environment variable, you can use shortened commands to start the Derby tools. Otherwise, either you must be in the directory where the script that starts the Derby tool is located, or you must specify the full path to the location of the script when you want to start the tool.

For more information on the scripts included in the bin distribution, see Scripts included with Derby.
Parent topic: Setting up your environment