EDN Code Exchange

Updated Sep 29, 2010

How to Use the Java Samples

This topic provides general information on how to use the Java command line and application samples. Additionally, each sample has a help topic with detailed instructions on how to use that particular sample.

Source Code Location

The source code for Java samples is located throughout the 'developerkit/samples' folder in your ArcGIS install location. It is organized into top level folders such as Controls, Geodatabase, and so on. Each folder has a collection of zip files. The zip file names are composed of the sample name and the programming language. Thus you can find the DrawText sample in the Controls folder as DrawTextCSharp.zip, DrawTextJava.zip and others.

Also, from the Code Exchange on the ESRI Developer Network (EDN) Web site (http://edn.esri.com), you can view every sample page and download its associated source code files. The site also includes new samples added since the last release.

Setting up the Runtime Environment

Before using the samples, your runtime environment must be set up. If you are a developer and have your development environment set up, you do not need to complete this step, as the development environment will allow samples to run.

Instructions for setting up your ArcGIS Java development/runtime environment can be found at: ArcGIS Engine Java Programming

Extract Source Project

  • Use a zip tool to extract the zip file, or use the Jar tool which comes with the Java Developer Kit to unpack the zip file.
  • The basic command to use for extracting the contents is: jar xf zip-file.
  • This creates a directory and populates it with an ANT project structure with all the source files for the sample.

Compile and Running Samples

  • CD into the sample folder
    $ cd [source]
  • Edit the sample.properties file with the correct command line parameters - note: most GUI samples do not require editing the sample.properties file.
  • ArcGIS Engine Developer Kit provides a specific version of ANT called ARCGISANT
  • Build scripts for ArcGIS Engine samples have 5 useful tasks which are described below:
  • $ arcgisant
    compiles all source code
  • $arcgisant clean
    cleans up all build products
  • $arcgisant dist
    creates distributable products, i.e., jar file
  • $ arcgisant help
    usage description
  • $arcgisant execute
    runs the sample