Getting Started with the Java API

Get to know how to configure JAVA APIs.

Requirements

  • GGS distribution (ggs-dist-{version}.zip)
    • Once unzipped, you'll need the GGS SDK CLI located in "{directory}/ggs-dist-{version}/cli"
  • Dataset(s) in the Spectrum data format (*.spd)
  • For additional detail, see System Requirements.

Placeholders

The following conventions are used as placeholders for some common items:
  • {directory} Any directory where you would like to install the resources for the SDK.
  • {version} The version of the GGS SDK such as 4.0.2.
  • {spd} Dataset in the Spectrum data format. For example, KGD082019.spd.

Open the Sample Code in IDE

  1. Extract the zipped Global Geocoding SDK (GGS) distribution to an empty directory. For example: {directory}/ggs-dist-{version}. The following directories will be created:
    • cli – contains the command-line interface (CLI) Utility used to configure GGS. [About the Geocoding CLI Utility.]
    • resources – contains runtime resources for the GGS API.
    • sdk – contains resources for the JAVA API development, including addressing and geocoding sample code.
    • webapp – contains the REST API distribution war file ‘Geocode-{version}.war’ [About deploying a war file.]
  2. Open the sample project in {directory}/ggs-dist-{version}/sdk/samples/ggs-javaapi-sample.
    1. Review the README.md for getting started with the sample project code.
    2. For additional detail, see the JAVA docs in {directory}/ggs-dist-{version}/sdk/javadoc.

Install and Configure Datasets

Before using a service, install and configure the data for the SDK. There are two options:

  • Configure using the GGS CLI if you want your configuration to persist for future calls to the API.
  • Configure programmatically if you want your configuration to apply only to that runtime. View examples.

Configure using the GGS CLI

  1. Create a location where datasets will be installed.
    1. Windows:
      mkdir {directory}/data
    2. Linux:
      mkdir -p {directory}/data
  2. Run the GGS CLI. The command below starts the CLI in autocomplete mode.
    Note: The GGS CLI can be run in autocomplete or batch mode. [About the CLI Batch Process.]
    1. Windows:
      cd {directory}/ggs-dist-{version}/cli
      cli.cmd
    2. Linux:
      cd {directory}/ggs-dist-{version}/cli
      cli.sh
  3. Locate .spd file(s) and extract the dataset(s). [About the Extract command.]
    extract --s "{spd}" --d "{directory}/data"
  4. Configure data for the SDK, based on the dataset location, by running this command from within the autocomplete CLI. [About the Configure command.]
    configure --s "{directory}/data" --d "{directory}/ggs-dist-{version}/resources/config"

    The "–d" parameter indicates the location of the configuration. It must be in the directory as specified in the above command. To test your configuration, copy this path and use it to build a geocoder.

Use the configuration

Geocoding API Examples (Java)

Geo Addressing API Examples (Java)