Detecting version of ArcGIS

273
2
06-20-2012 11:44 AM
by Anonymous User
Not applicable
Hello
I've recently taken over development on a project that supports multiple versions of ArcGIS, with different code paths for each version. Previously, the version check was done by the presence of the specific environment variable containing the path to the ArcGIS Desktop install, and the successful loading of the arcobjects.jar. 

For example, for ArcGIS 10.0:

String arcEngineHome = System.getenv("AGSDESKTOPJAVA"); //Env variable for ArcGIS 10.0
String jarPath = arcEngineHome + "java\\lib\\arcobjects.jar";
File f = new File(jarPath);

// If the jar isn't in the specified path, we can't load the ESRI plugin
if (!f.exists()) 
 return false;


and for ArcGIS 9.3:

String arcEngineHome = System.getenv("ARCGISHOME"); //Env variable for ArcGIS 9.3
String jarPath = arcEngineHome + "java\\lib\\arcobjects.jar";
File f = new File(jarPath);

// If the jar isn't in the specified path, we can't load the ESRI plugin
if (!f.exists()) 
 return false;


While messy, this has worked for us until recently with the release of 10.1.  We have run into an issue because both 10.0 and 10.1 both utilize the AGSDESKTOPJAVA environment variable.

What would be the best way of checking the version of ArcGIS installed on a user's machine?

Thanks!
0 Kudos
2 Replies
JohnHauck
Occasional Contributor II
I don't believe you can rely on "10.0" or "10.1" being in the product directory name. I also doubt all users would have access to the registry to check the "RealVersion" key. I've not tested on a Java only machine but it looks like Java also has access to IArcGISVersion. If you know it's 10.0 or 10.1 you could check the version here.
0 Kudos
by Anonymous User
Not applicable
...If you know it's 10.0 or 10.1 you could check the version here.


That's my problem there though... at this point I'm not sure what version of ArcGIS the user has installed.
0 Kudos