This repo contains a set of sample projects demonstrating how to accomplish various mapping and GIS tasks with the ArcGIS Runtime API for Java.
Browse the category directories to explore the samples. Each sample is an individual Gradle project that can be run standalone. The Gradle buildscripts have tasks for running the application, building a jar, and distributing the app as a zip.
Installing Gradle is not necessary since each sample includes the Gradle wrapper.
Accessing Esri location services, including basemaps, routing, and geocoding, requires authentication using either an ArcGIS identity or an API Key:
- ArcGIS identity: An ArcGIS named user account that is a member of an organization in ArcGIS Online or ArcGIS Enterprise.
- 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.
Note: in the following instructions for setting the API key, 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.
- Open IntelliJ IDEA and select File > Open....
- Choose one of the sample project directories (not the category folder) and click OK.
- Select File > Project Structure... and ensure that the Project SDK and language level are set to use Java 11.
- 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.apiKey = yourApiKey
- Open the Gradle view with View > Tool Windows > Gradle.
- 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.
- Open Eclipse and select File > Import.
- In the import wizard, choose Gradle > Existing Gradle Project, then click Next.
- Choose one of the sample project directories (not the category folder) as the project root directory.
- Click Finish to complete the import.
- 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.apiKey = yourApiKey
- Open the Gradle Tasks view with Window > Show View > Other... > Gradle > Gradle Tasks.
- In the Gradle Tasks view, double-click the
run
task under {project_name} > application to run the app.
cd
into one of the sample project directories (not the category folder).- Run
gradle wrapper
to create the Gradle Wrapper - 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. - Run
./gradlew run
on Linux/Mac orgradlew.bat run
on Windows to run the app.
Java 11 users may find exceptions when running the project if their library path is still set for Oracle JDK 1.8 (see the OpenJavaFX docs for more information). A workaround for this is to add the following argument in the run
task of the Gradle buildscript:
systemProperty "java.library.path", "C:\tmp"
Some samples require offline data. A samples-data
directory will automatically download to the project root when the Gradle project is configured/imported.
See the ArcGIS Runtime API's system requirements.
Find a bug or want to request a new feature? Please let us know by submitting an issue.
Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.
New to Git? Check out our Working with Git guide.
Copyright 2021 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.