18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING A COMMAND-LINE JAVA APPLICATION<br />

Initializing ArcObjects<br />

Every application built with the <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> Kit must initialize<br />

ArcObjects at a product level, including any appropriate extension licenses. The<br />

AoInitialize object is used to accomplish this task. This class initializes the<br />

ArcObjects runtime environment and must be the first ArcObjects component<br />

created. Two methods will be called from this object:<br />

• initialize(int product code)—This method takes an integer value representing a<br />

product code. The Java API provides an interface called esriLicenseProductCode,<br />

which exposes static integer fields representing the different ESRI product<br />

levels. See the javadoc description for a full list of products.<br />

• CheckOutExtension(int extensioncode)—This method takes an integer value representing<br />

an extension license code. The Java API provides an interface called<br />

esriLicenseExtensionCode, which exposes static integer fields representing the<br />

different ESRI extension products available.<br />

This application requires an <strong>ArcGIS</strong> <strong>Engine</strong> Runtime license with 3D Analyst<br />

extension license.<br />

1. Declare a static AoInitialize variable and create the signature for this method as<br />

follows:<br />

private static AoInitialize aoInit;<br />

private static void licenseCheckOut(){}<br />

2. Implement the private method.<br />

/**<br />

* Initialize ArcObjects product usage and check out<br />

* available 3D Analyst extension license.<br />

*/<br />

private static void licenseCheckOut(){<br />

try{<br />

aoInit = new AoInitialize();<br />

aoInit.initialize(esriLicenseProductCode.esriLicenseProductCode<strong>Engine</strong>);<br />

aoInit.checkOutExtension(esriLicenseExtensionCode.<br />

esriLicenseExtensionCode3DAnalyst);<br />

}catch(IOException e){<br />

System.out.println("Program Exit: Unable to initialize ArcObjects");<br />

System.exit(0);<br />

}<br />

}<br />

Putting it all together<br />

Now that the private methods have all been constructed, you need to create an<br />

entry point for your application. This main method will take command-line<br />

arguments and pass them to the tinToPoint method created in earlier steps.<br />

422 • <strong>ArcGIS</strong> <strong>Engine</strong> <strong>Developer</strong> <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!