In this topic
ArcGIS Engine samples
The ArcGIS Engine samples provided by ESRI are simple tools for developers to understand and implement the essential features of ArcGIS Engine in their application. Sample code can be browsed<span> by clicking the links in the Example Code section on the sample's description. Additionally, samples can be viewed in a javadoc-like environment, where all sample packages, classes, and elements can be viewed as a whole, then selected individually for code examination.
Samples can be run as follows:
- At the command line
- Using the Eclipse integrated development environment (IDE)
- Using arcgisant
The samples are located on disk in the <ArcGISInstallDirectory>\java\samples\arcobjects\<sample name> folder. For convenience, each sample is built into an executable Java Archive (JAR) file, which can be executed on any UNIX or Windows command line. The descriptions for each sample can be found in the corresponding example.html.
If you have installed the Java Runtime Environment (JRE) on your system, run the following commands at the command line to execute the sample JAR file:
- cd %AGSDEVKITJAVA%/java/samples/arcobjects/<sample name>/bin
- java –jar <sample name>.jar
In UNIX, to run samples from the command line, the init_java.sh or init_java.csh at location %AGSDEVKITJAVA% should be sourced depending on the user shell. For more information, see Post installation.
If you plan to use the Eclipse IDE to run samples, make sure the ArcGIS plug-ins for Eclipse IDE are installed. If the ArcGIS plug-ins are not installed, the corresponding Eclipse project will not build. For more information, see How to install ArcGIS plug-ins.
On Linux machines, to avoid seeing crashes due to Standard Widget Toolkit (SWT) internal errors, ensure you have a GTK2 version of Mozilla (1.6 or higher) installed on your machine and set the MOZILLA_FIVE_HOME environment variable to point to the browser's installation folder. For more information, see The SWT FAQ on the Eclipse Web site.
To import an ArcGIS Engine sample as an Eclipse project, do the following steps:
- On the Eclipse main toolbar, click File, New, and Project. In the New Project wizard, click the ESRI Templates node, ArcGIS Engine Sample, then click Next. See the following screen shot:
- The New ArcGIS Engine Sample Project dialog box shows all samples provided by ESRI. The descriptive topic area on the right gives detailed information about the selected sample. Select the applicable sample and click Finish. See the following screen shot:
- The selected sample is imported as an Eclipse project. To view the source code, select the Java file in the corresponding project. To run the sample, right-click the Java file and click Run As, then click Java application. See the following screen shot:
The description for the corresponding sample can be found in example.html in the same project folder. See the following screen shot:
ArcGIS Engine also provides the arcgisant tool (a version of Ant). After configuring the arcgisant tool, run the samples using the following commands on the command line window or shell:
- cd %AGSDEVKITJAVA%\java\samples\arcobjects\<sample folder>
- arcgisant run-sample
For more information on how to configure arcgisant, see Post installation.
See Also:How to install ArcGIS plug-ins
How to add code snippets and samples
The SWT FAQ
|Development licensing||Deployment licensing|
|Engine Developer Kit||Engine|