background image
<< Syntax for the derbyrun.jar file | Using the Derby tools and startup utilities >>
<< Syntax for the derbyrun.jar file | Using the Derby tools and startup utilities >>

Manually setting the CLASSPATH environment variable

Getting Started with Derby
14
You cannot use the
-cp
argument or the CLASSPATH environment variable to set
CLASSPATH variables when you are using the
-jar
argument to start the
ij
tool.
If you want to run the
ij
tool with a custom classpath, you cannot use the
-jar
argument. Instead, you have to use the full class name to start the
ij
tool (
java
org.apache.derby.tools.ij
).
See
Manually setting the CLASSPATH environment variable
for more information about
setting up the classpath and running the
ij
tool.
There is no such limitation when you run the
sysinfo
tool. See
Running sysinfo
for
more information on running the
sysinfo
tool.
The
server
argument is a shortcut for running the
NetworkServerControl
tool. For
details on using this tool, see the Derby Server and Administration Guide.
For more information on using
derbyrun.jar
to run the
ij
,
sysinfo
, and
dblook
tools, see the Derby Tools and Utilities Guide.
Manually setting the CLASSPATH environment variable
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.
Derby provides several scripts in the DERBY_HOME
/bin
directory to help you set your
classpath quickly. These scripts are:
setEmbeddedCP
Use the setEmbeddedCP script to set the classpath when the database engine is
used in embedded mode. This script adds the
derby.jar
and
derbytools.jar
files to the classpath.
setNetworkServerCP
Use the setNetworkServerCP script to set the classpath when you want to start the
network server. This script adds the
derbynet.jar
file to the classpath.
setNetworkClientCP
Use the setNetworkClientCP script to set the classpath when you want to access
databases using the network client. This script adds the
derbyclient.jar
and
derbytools.jar
files to the classpath.
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.