Skip to content

Esri/arcgis-maps-sdk-java-samples

Repository files navigation

ArcGIS Maps SDK for Java Samples

Link: ArcGIS Developers home Link: Documentation Link: API Reference Link: Tutorials Link: Demos Link: Toolkit

Link: Esri Community ArcGIS Developers Twitter Link: ArcGIS Maps SDKs for Native Apps Blog Link: ArcGIS Blog for Developers

Gradle build

Welcome to the ArcGIS Maps SDK for Java Samples repository.

The ArcGIS Maps SDK for Java is used to build mapping, location, and GIS applications for desktop applications running on Windows, Mac, or Linux. This repo contains a set of sample projects demonstrating how to accomplish various mapping and geospatial tasks with the ArcGIS Maps SDK for Java.

Sections

Sample viewer

You can browse our samples by downloading our Sample Viewer Application.

Java Sample Viewer

Running the samples locally via this project

Each sample is an individual Gradle project that can be run standalone. Installing Gradle is not necessary since each sample includes the Gradle wrapper.

Pre-requisites:

Manually via the IDE:

  1. Open IntelliJ IDEA and select File > Open....
  2. Choose one of the sample project directories (e.g. display-map) and click OK.
  3. Select File > Project Structure... and ensure that the Project SDK and language level are set to use Java 17.
  4. Store your API key in the gradle.properties file located in the /.gradle folder within your home directory. The API key will be set as a Java system property when the sample is run.

Note: if a gradle.properties file does not already exist in the /.gradle folder within your home directory, a Gradle task in the samples build.gradle file will generate one for you to populate with your API key.

apiKey = yourApiKey
  1. Open the Gradle view with View > Tool Windows > Gradle.
  2. In the Gradle view, double-click the run task under Tasks > application to run the app.

Note: if you encounter the error Could not get unknown property 'apiKey' for task ':run' of type org.gradle.api.tasks.JavaExec. you may have to set the Gradle user home in the IntelliJ Gradle settings to the /.gradle folder in your home directory.

Via the terminal:

  1. cd into one of the sample project directories (e.g. display-map).
  2. Run gradle wrapper to create the Gradle Wrapper
  3. Store your API key in the gradle.properties file located in the /.gradle folder within your home directory. The API key will be set as a Java system property when the sample is run.
  4. Run ./gradlew run on Linux/Mac or gradlew.bat run on Windows to run the app.

Setup an API key

Accessing Esri location services, including basemaps, routing, and geocoding, requires authentication using either an ArcGIS identity or an API Key:

  1. ArcGIS identity: An ArcGIS named user account that is a member of an organization in ArcGIS Online or ArcGIS Enterprise.
  2. API key: A permanent key that gives your application access to Esri location services. Visit your ArcGIS Developers Dashboard to create a new API key or access an existing API key.

Offline sample data

Some samples require offline data. A samples-data directory will automatically download to the project root when the Gradle project is configured/imported.

System requirements for ArcGIS Maps SDK for Java

See the ArcGIS Maps SDK for Java's system requirements.

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

New to Git? Check out our Working with Git guide.

Licensing

Copyright 2023 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

http://www.apache.org/licenses/LICENSE-2.0

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.

A copy of the license is available in the repository's license.txt file.