Setting Up the Product Examples

Setting Up the Product Examples

The GemFire examples are included in the distribution file that contains your GemFire software. Set up your environment to run these examples as described in this section.

After you download Pivotal GemFire, you can run the examples to explore GemFire's feature set and evaluate the software.


  • Install GemFire on each physical or virtual machine on which you will run the Pivotal GemFire examples as described in Installing Pivotal GemFire.
  • Set your JAVA_HOME, PATH, GEMFIRE, and GF_JAVA environment variables as follows:
    • Configure the JAVA_HOME environment variable.
      export JAVA_HOME
    • Add GemFire scripts to your the PATH environment variable. For example:
      export PATH
    • Set the GEMFIRE environment variable to point to your GemFire installation top-level directory. (You should see bin, lib, dtd, and other directories under GEMFIRE.) The following variables definitions are examples; your installation path may vary depending on where you install GemFire and the version you are installing.
      export GEMFIRE
    • Configure your GF_JAVA environment variables as shown in these examples. GF_JAVA must point to the java executable file under your JAVA_HOME. (If you have not done so already, you should also set your JAVA_HOME variable to a supported Java installation.)
      export GF_JAVA  

Examples Included with Pivotal GemFire

The following examples are included in the SampleCode directory from your GemFire product download.

Table 1. GemFire Examples
Example Example Code Location Documentation Location
Hello World

A simple demonstration of GemFire data distribution.

SampleCode/helloworld Pivotal GemFire User's Guide: Hello World Example
Pivotal GemFire Tutorial

A guided tour of Pivotal GemFire's core features.

SampleCode/tutorial Pivotal GemFire User's Guide: Pivotal GemFire Tutorial
QuickStart Examples

Demonstrates the following GemFire features:

  • Benchmark examples:
    • Peer to peer
    • Client-server
  • Cache eviction
  • Cache expiration
  • Delta propagation
  • Distributed locking
  • Fixed partitioning
  • Function execution
  • JSON
  • Management and monitoring
  • Multiple secure client
  • Overflowing data to disk
  • Partitioned data caching
  • Persisting data
  • Querying
  • Replicated caching
  • Reliable event notifications:
    • Interest registration
    • Continuous querying
    • Durable event messaging
  • Secure client
  • Server-managed caching
  • Transactions
SampleCode/quickstart Pivotal GemFire User's Guide:QuickStart Examples
Programming Examples

The following examples demonstrate how to write applications using the Pivotal GemFire Java API:

  • Cache overflow
  • Cache runner
  • Client API
  • Client/Server configurations
  • Delta propagation
  • High availability overflow
  • Partitioned persistence
  • Portable data exchange serialization (PDX)
  • Transactions
  • WAN: active data

Documentation for the Programming Examples is available in the following files in the SampleCode directory of your GemFire download:

Examples guide:



(Each example subdirectory contains a README.html file with the documentaiton for that example.)

Examples Javadocs:



OSGi Examples

The following examples demonstrate how to deploy GemFire applications into an OSGi environment:

  • cacheWorker
  • cacheWorkerFragment



What to do next
Note: The Spring Data GemFire project enables developers to use the Spring Data GemFire API to write applications and configure a GemFire system.