You can set the CLASSPATH environment variable in the operating system either temporarily, permanently, or at run time when you start your Java application and the JVM.
The classpath is a list of the class libraries that are needed by the JVM and other Java applications to run your program. There are scripts that are included with Derby that can set up the classpath to run the Derby tools.
If you want to call the Derby tools directly using Java and not using the scripts, you must manually set the CLASSPATH environment variable.
In most development environments, it is best to temporarily set the CLASSPATH environment variable in the command line shell where you are entering commands.
To set the classpath temporarily, run the script that is appropriate for your environment every time that you open a new command window.
Note that these scripts behave slightly differently on UNIX systems and on Windows systems. On Windows systems, running the script in your command shell will set the environment variables for your shell.
On UNIX systems, you need to use the "dot" or "source" command to ensure that the script is run in the calling shell's environment. Otherwise, when a script is run, it launches a new shell for that script. The CLASSPATH is set within that shell. Once the script is complete, that shell exits and you are returned to your shell. The CLASSPATH is changed only for the shell that the script was running in. The CLASSPATH in your shell is unchanged.
The UNIX shell scripts are known to run successfully in the Bash shell, and you may need to modify them slightly if you are using a different UNIX shell.
sh-2.05b$ echo $CLASSPATH sh-2.05b$ DERBY_HOME=/derby/db-derby-10.X.Y.0-bin sh-2.05b$ . $DERBY_HOME/bin/setEmbeddedCP sh-2.05b$ echo $CLASSPATH /derby/db-derby-10.X.Y.0-bin/lib/derby.jar:/derby/db-derby-10.X.Y.0-bin/lib/derbytools.jar: sh-2.05b$ java org.apache.derby.tools.ij ij version 10.X ij> quit;
-bash-2.05b$ echo $CLASSPATH -bash-2.05b$ export DERBY_HOME=/derby/db-derby-10.X.Y.0-bin -bash-2.05b$ source $DERBY_HOME/bin/setEmbeddedCP
C:\derby\db-derby-10.X.Y.0-bin\bin>echo %CLASSPATH% %CLASSPATH% C:\derby\db-derby-10.X.Y.0-bin\bin>set DERBY_HOME=C:\derby\db-derby-10.X.Y.0-bin C:\derby\db-derby-10.X.Y.0-bin\bin>setEmbeddedCP.bat C:\derby\db-derby-10.X.Y.0-bin\bin>echo %CLASSPATH% C:\derby\DB-DERBY-10.X.Y.0-bin\lib\derby.jar;C:\derby\DB-DERBY-10.X.Y.0-bin\lib\derbytools.jar; C:\derby\db-derby-10.X.Y.0-bin\bin>java org.apache.derby.tools.ij ij version 10.X ij> quit;