You can set the CLASSPATH and MODULEPATH environment variables 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. Similarly, the modulepath is a corresponding list of Java modules needed by your program. There are scripts that are included with Derby that can set up the classpath/modulepath 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 or manually declare a modulepath.
In most development environments, it is best to temporarily set these variables in the command line shell where you are entering commands.
To set the classpath and modulepath 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 and MODULEPATH variables are set within that shell. Once the script is complete, that shell exits and you are returned to your shell. CLASSPATH/MODULEPATH are changed only for the shell that the script was running in. The CLASSPATH and MODULEPATH variables in your shell are 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/derbyshared.jar:/derby/db-derby-10.X.Y.0-bin/lib/derby.jar:/derby/db-derby-10.X.Y.0-bin/lib/derbytools.jar:/derby/db-derby-10.X.Y.0-bin/lib/derbyoptionaltools.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\derbyshared.jar;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\lib\derbyoptionaltools.jar; C:\derby\db-derby-10.X.Y.0-bin\bin>java org.apache.derby.tools.ij ij version 10.X ij> quit;