CLASSPATH Settings for GemFire Processes

This topic describes how GemFire processes set their CLASSPATH.

When starting a server or locator process using gfsh (or the deprecated cacheserver script), the required application JAR files are automatically loaded into the process's CLASSPATH for you.

If you are starting a GemFire process programmatically (standalone or embedded), we recommend that you specify the CLASSPATH upon program execution using the java -classpath or java -cp command-line option. This method is preferred over setting the CLASSPATH as an environment variable since it allows you to set the value individually for each application without affecting other applications and without other applications modifying its value.

For example, to start up a GemFire locator process using the LocatorLauncher API, you can execute the following on the command line:
prompt# java -cp "$GEMFIRE/lib/gemfire.jar:\
$GEMFIRE/lib/antlr.jar:\
$GEMFIRE/lib/gfsh-dependencies.jar:\
$GEMFIRE/lib/gfSecurityImpl.jar:\
$GEMFIRE/lib/jackson-core-asl-1.9.9.jar:\
$GEMFIRE/lib/commons-logging.jar:\
$GEMFIRE/lib/tomcat-embed-core.jar:\
$GEMFIRE/lib/tomcat-embed-logging-juli.jar:\
$GEMFIRE/lib/tomcat-embed-jasper.jar:\
$JAVA_HOME/lib/tools.jar" \
com.gemstone.gemfire.distributed.LocatorLauncher start locator1 <locator-launcher-options>
Note: This example command assumes you have defined JAVA_HOME and GEMFIRE environment variables as described in the installation topic for your platform.
To start up a GemFire server process using the ServerLauncher API:
prompt# java -cp "$GEMFIRE/lib/gemfire.jar:\
$GEMFIRE/lib/antlr.jar:\
$GEMFIRE/lib/gfsh-dependencies.jar:\
$GEMFIRE/lib/gfSecurityImpl.jar:\
$GEMFIRE/lib/jackson-core-asl-1.9.9.jar:\
$GEMFIRE/lib/commons-logging.jar:\
$GEMFIRE/lib/tomcat-embed-core.jar:\
$GEMFIRE/lib/tomcat-embed-logging-juli.jar:\
$GEMFIRE/lib/tomcat-embed-jasper.jar:\
$JAVA_HOME/lib/tools.jar":\
/path/to/your/applications/classes.jar" \
com.gemstone.gemfire.distributed.ServerLauncher start server1 <server-launcher-options>
Note: This example command assumes you have defined JAVA_HOME and GEMFIRE environment variables as described in the installation topic for your platform.

Note that in addition to the library JAR files required to run GemFire, you must also specify any custom application JARs that you wish to access in your GemFire process. For example, if you are planning on running a custom application on your regions, you should specify the application JAR that contains the application you wish to use.

To start up an application with an embedded cache:
java -cp "$GEMFIRE/lib/gemfire.jar:\
$GEMFIRE/lib/antlr.jar:\
$GEMFIRE/lib/gfsh-dependencies.jar:\
$GEMFIRE/lib/gfSecurityImpl.jar:\
$GEMFIRE/lib/jackson-core-asl-1.9.9.jar:\
$GEMFIRE/lib/commons-logging.jar:\
$GEMFIRE/lib/tomcat-embed-core.jar:\
$GEMFIRE/lib/tomcat-embed-logging-juli.jar:\
$GEMFIRE/lib/tomcat-embed-jasper.jar:\
$JAVA_HOME/lib/tools.jar":\
/path/to/your/applications/classes.jar" \
com.mycompany.package.ApplicationWithEmbeddedCache
Note: Another method for updating the CLASSPATH of a server process with your own applications is to use the gfsh deploy command. Deploying application JAR files will automatically update the CLASSPATH of all members that are targeted for deployment. See Deploying Application JARs to Pivotal GemFire Members for more details.