Hello,I have a simple console application developed in Java. It works fine in the NetBeans IDE, but when I try to run the jar file from a command line (Windows XP) I get this error message: "Unable to initialize ArcObjects environment. AutomationException: 0x800401f5 - The specified product or version does not exist on this machine. in 'ArcGISVersion.Version'". This error is triggered by the EngineInitializer.initializeEngine() line of my code. Of course, I do have ArcGIS 10 installed on my machine, and this error does not happen in NetBeans IDE.The main class of my application is the Bootstrapper I found somewhere on this forum and it is working well (its purpose is to locate the arcobjects.jar). The error happens later, when I try to initialise the engine.Here are snippets of my code:The method causing the error:
public static void main(String[] args) {
try {
// Initialise ArcGIS
EngineInitializer.initializeEngine(); // This line triggers the error
AoInitialize aoInit = new AoInitialize();
initializeArcInfoLicense(aoInit);
INetworkQuery networkQuery =openNetworkQuery(args[0], args[1], args[2]);
computeMetrics(networkQuery);
// Release the license.
aoInit.shutdown();
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
} //End of method main.The bootstrapper class:
public class Bootstrapper {
public static void main(String[] args)throws Exception{
bootstrapArcobjectsJar();
//Replace the following line with the name of your main application.
// App.main(args);
TopologicalMetrics.main(args);
System.out.println("done.");
}
public static void bootstrapArcobjectsJar(){
String arcEngineHome = System.getenv("ARCGISHOME");
String jarPath = arcEngineHome + "java" + File.separator + "lib" +
File.separator + "arcobjects.jar";
File f = new File(jarPath);
URLClassLoader sysloader = (URLClassLoader)ClassLoader.getSystemClassLoader()
;
Class sysclass = URLClassLoader.class;
try{
Method method = sysclass.getDeclaredMethod("addURL", new Class[]{
URL.class
}
);
method.setAccessible(true);
method.invoke(sysloader, new Object[]{
f.toURL()
}
);
}
catch (Throwable t){
t.printStackTrace();
System.err.println("Could not add arcobjects.jar to system classloader");
}
}