ArcGIS Runtime SDK for Java

Local Server Geoprocessing

Demonstrates how to create contour lines from local raster data using a local geoprocessing package (.gpk) and the contour geoprocessing tool.

Note: Local Server is not supported on MacOS

How it works

To start a GeoprocessingTask that generates contour lines from raster data:

  1. Add raster data to map using as an ArcGISTiledLayer.
  2. Create and run a LocalServer.
    • LocalServer.INSTANCE creates a local server
    • Server.startAsync() starts the server asynchronously
  3. Wait for server to be in the LocalServerStatus.STARTED state.
    • Server.addStatusChangedListener() fires whenever the running status of the local server has changed.
  4. Start a LocalGeoprocessingService and run a GeoprocessingTask.
    • new LocalGeoprocessingService(Url, ServiceType), creates a local geoprocessing service
    • LocalGeoprocessingService.startAsync() starts the geoprocessing service asynchronously
    • new GeoprocessingTask(LocalGeoprocessingService.getUrl() + "/Contour"), creates a geoprocessing task that uses the contour lines tool
  5. Create GeoprocessingParameters and add a GeoprocessingDouble as a parameter using set interval.
    • new GeoprocessingParameters(ExecutionType), creates geoprocess parameters
    • GeoprocessingParameters.getInputs().put("Interval", new GeoprocessingDouble(double)), creates a parameter with name `Interval` with the interval set as its value.
  6. Create and start a GeoprocessingJob using the parameters from above.
    • GeoprocessingTask.createJob(GeoprocessingParameters), creates a geoprocessing job
    • GeoprocessingJob.start(), starts job
  7. Add contour lines as an ArcGISMapImageLayer to map.
    • get url from local geoprocessing service, LocalGeoprocessingService.getUrl()
    • get server job id of geoprocessing job, GeoprocessingJob.getServerJobId()
    • replace `GPServer` from url with `MapServer/jobs/jobId`, to get generate contour lines data
    • create a map image layer from that new url and add that layer to the map


 * Copyright 2017 Esri.
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.

package com.esri.samples.localserver.local_server_geoprocessing;


import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class LocalServerGeoprocessingSample extends Application {

  private static LocalServerGeoprocessingController controller;

  public void start(Stage stage) throws IOException {
    // set up the scene
    FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/local_server_geoprocessing.fxml"));
    Parent root = loader.load();
    controller = loader.getController();
    Scene scene = new Scene(root);

    // set up the stage
    stage.setTitle("Local Server Geoprocessing Sample");

   * Stops and releases all resources used in application.
  public void stop() {

   * Opens and runs application.
   * @param args arguments passed to this application
  public static void main(String[] args) {


In this topic
  1. How it works
  2. Code