Demonstrates how to start and stop the Local Server and start and stop a local map, feature, and geoprocessing service running on the Local Server.
Use case
For executing offline geoprocessing tasks in your ArcGIS Maps SDK for Java apps via an offline (local) server.
How to use the sample
Choose an option from the dropdown control to filter packages by service type. Then click the Open button to choose a package. Finally, click the Start button to start the service. The service's status will be displayed in the center log.
To stop a service, select it from the Running Services list and click the Stop Service button. To go to the service's URL in your default web browser, select it and click the Go to URL button.
How it works
To start a LocalServer and attach a LocalService:
Create and run a local server with LocalServer.INSTANCE.
Start the server asynchronously with Server.startAsync().
Wait for server to be in the LocalServerStatus.STARTED state.
Callbacks attached to Server.addStatusChangedListener() will invoke whenever the status of the local server has changed.
Create and run a local service. Here is an example of running a LocalMapService:
Instantiate LocalMapService(Url) to create a local map service with the given URL path to map package (mpk or mpkx file).
Start the job with LocalMapService.startAsync().
The service is added to the LocalServer automatically.
To stop a LocalServer and any attached LocalServices:
If required, you can retrieve a list of all running services with LocalServer.INSTANCE.getServices().
Stop the services asynchronously using LocalService.stopAsync().
Use LocalServer.INSTANCE.stopAsync() to stop the server asynchronously. You can use .addDoneListener() on this process to perform additional actions after the server is successfully stopped, such as removing temporary files.
Relevant API
LocalFeatureService
LocalGeoprocessingService
LocalMapService
LocalServer
LocalServerStatus
LocalService
Additional information
Local Server can be downloaded for Windows and Linux platforms from your ArcGIS Developers dashboard. Local Server is not supported on macOS.
Specific versions of ArcGIS Maps SDK for Local Server are compatible with the version of ArcGIS Pro you use to create geoprocessing and map packages. For example, the ArcGIS Maps SDK for Java v100.11.0 is configured for ArcGIS Maps SDK for Local Server v100.10.0 which provides compatibility for packages created with ArcGIS Pro 2.7.x. For more information see the ArcGIS Developers guide.
To configure the ArcGIS Maps SDK for Java v100.11.0 to work with ArcGIS Maps SDK for Local Server 100.9.0:
Development machine:
Locate the Local Server installation directory and rename the folder from LocalServer100.9 to LocalServer100.10.
Update the environment variable from RUNTIME_LOCAL_SERVER_100_9 to RUNTIME_LOCAL_SERVER_100_10.
Deployment machine(s): Rename the deployment folder included with your application (or referenced by the LocalServerEnvironment.InstallPath property) from LocalServer100.9 to LocalServer100.10.
Tags
feature, geoprocessing, local services, map, server, service