Wednesday, August 22, 2007

Migrating ArcGIS Server Java Code from 9.1 to 9.2

When upgrading a ArcGIS Server Java application from ArcGIS Server 9.1 to 9.2, you'll notice that the way you instantiate objects from the server context has changed (become deprecated). The new method follows a more conventional Java cast.

Below are some examples based on a utility class used in symbolizing a polygon element for a buffer operation.

So for example in ArcGIS Server 9.1 to instantiate IRgbColor we would do the following:
IRgbColor color = new RgbColor(this.sc.createObject(RgbColor.getClsid()));

Whereas in ArcGIS Server 9.2 we do the following:
IRgbColor color = (IRgbColor) this.sc.createObject("esriDisplay.RgbColor");

The full source code for the files is available at geoVelocity's website:
http://www.geovelocity.com/downloads/RgbColorSample.zip



3 comments:

Anonymous said...

Also, you will want to refer to this document on EDN:

http://edndoc.esri.com/arcobjects/9.2/Java/java/engine/working_api/castingrt.html

geoneubie said...

Thanks for the tip!

Let me know if you ever want to make a post related to your ArcEngine development, I'd like to have as many people contribute as possible!

cheers,
Dave
info[at]mapportal.net

Anonymous said...

Thanks for the offer... if I have some time, i'll take you up on it.

I'm doing a lot of ArcGIS Server web-service work in addition to some ArcEngine.