I want to generate the executable jar file for my application, so i used the export tool in eclipse with the extract required libraries into generated JAR option, but when i run it with command line the EngineInitializer failed(the output error at the end), i'm bootstrapping with this class
package Deploy;
import java.io.File;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import Interface.SondageOCP;
public class Bootstrapper{
public static void main(String[] args)throws Exception{
bootstrapArcobjectsJar();
SondageOCP.main(args);
//Replace ApplicationName with your application's main class
}
public static void bootstrapArcobjectsJar(){
//Get the ArcGIS Engine runtime, if it is available
String arcObjectsHome = System.getenv("AGSENGINEJAVA");
//If the ArcGIS Engine runtime is not available, then we can try ArcGIS Desktop runtime
if(arcObjectsHome == null){
arcObjectsHome = System.getenv("AGSDESKTOPJAVA");
}
//If no runtime is available, exit application gracefully
if(arcObjectsHome == null){
if(System.getProperty("os.name").toLowerCase().indexOf("win") > -1){
System.err.println("You must have ArcGIS Engine Runtime or ArcGIS Desktop " +
"installed in order to execute this sample.");
System.err.println("Install one of the products above, then re-run this sample.");
System.err.println("Exiting execution of this sample...");
System.exit(0);
}else{
System.err.println("You must have ArcGIS Engine Runtime installed " +
"in order to execute this sample.");
System.err.println("Install the product above, then re-run this sample.");
System.err.println("Exiting execution of this sample...");
System.exit(0);
}
}
//Obtain the relative path to the arcobjects.jar file
String jarPath = arcObjectsHome + "java" + File.separator + "lib" +
File.separator + "arcobjects.jar";
//Create a new file
File jarFile = new File(jarPath);
//Test for file existence
if(!jarFile.exists()){
System.err.println("The arcobjects.jar was not found in the following location: " +
jarFile.getParent());
System.err.println("Verify that arcobjects.jar can be located in the specified folder.");
System.err.println("If not present, try uninstalling your ArcGIS software and reinstalling it.");
System.err.println("Exiting execution of this sample...");
System.exit(0);
}
//Helps load classes and resources from a search path of URLs
URLClassLoader sysloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
Class<URLClassLoader> sysclass = URLClassLoader.class;
try{
Method method = sysclass.getDeclaredMethod("addURL", new Class[]{URL.class});
method.setAccessible(true);
method.invoke(sysloader, new Object[]{jarFile.toURI().toURL()});
}catch (Throwable throwable){
throwable.printStackTrace();
System.err.println("Could not add arcobjects.jar to system classloader");
System.err.println("Exiting execution of this sample...");
System.exit(0);
}
}
}
and the The main called to open the app window is:
public static void main(String[] args) throws IOException {
EngineInitializer.initializeVisualBeans();
dao d=new dao();
open o=new open();
Sondage[] s=d.haveBD();
SondageOCP map = new SondageOCP(s,d);
o.setVisible(false);
map.setVisible(true);
}
And finally the output error is :
C:\Users\mouad\Desktop\SondageOCP>java -jar SondageOCP.jar
Could not load native libraries.
java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)
atcom.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source)
at Interface.SondageOCP.main(SondageOCP.java:282)
at Deploy.Bootstrapper.main(Bootstrapper.java:13)
Exception in thread "ArcGIS VisualBean Mode STA Thread" java.lang.UnsatisfiedLin
kError: com.esri.arcgis.interop.NativeObjRef.runMessagePump()V
at com.esri.arcgis.interop.NativeObjRef.runMessagePump(Native Method)
at com.esri.arcgis.interop.STAThread.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Could not load native libraries.
java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
java.lang.UnsatisfiedLinkError: no ntvinv in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at com.esri.arcgis.interop.NativeLoader.loadLibrary(Unknown Source)
at com.esri.arcgis.interop.NativeObjRef.p(Unknown Source)
at com.esri.arcgis.interop.Dispatch.a(Unknown Source)
at com.esri.arcgis.interop.Dispatch.isNativeMode(Unknown Source)
at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source)
at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source)
at com.esri.arcgis.version.IArcGISVersionProxy.<init>(Unknown Source)
at com.esri.arcgis.version.VersionManager.<init>(Unknown Source)
at com.esri.arcgis.version.VersionManager.<init>(Unknown Source)
at com.esri.arcgis.system.EngineInitializer.setVersionAndInitialize(Unknown Source)
at com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source)
at Interface.SondageOCP.main(SondageOCP.java:282)
at Deploy.Bootstrapper.main(Bootstrapper.java:13)
java.lang.RuntimeException: Failed to initialize native code invocation: null
at com.esri.arcgis.interop.NativeObjRef.p(Unknown Source)
at com.esri.arcgis.interop.Dispatch.a(Unknown Source)
at com.esri.arcgis.interop.Dispatch.isNativeMode(Unknown Source)
at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source)
at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source)
at com.esri.arcgis.version.IArcGISVersionProxy.<init>(Unknown Source)
at com.esri.arcgis.version.VersionManager.<init>(Unknown Source)
at com.esri.arcgis.version.VersionManager.<init>(Unknown Source)
at com.esri.arcgis.system.EngineInitializer.setVersionAndInitialize(Unknown Source)
at
com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknown Source)
at Interface.SondageOCP.main(SondageOCP.java:282)
at Deploy.Bootstrapper.main(Bootstrapper.java:13)
Exception in thread "main" java.lang.RuntimeException: Can not use native code:
Initialisation failed
at com.esri.arcgis.interop.NativeObjRef.<init>(Unknown Source)
at com.esri.arcgis.interop.Dispatch.createDispatch(Unknown Source)
at com.esri.arcgis.interop.Dispatch.<init>(Unknown Source)
at com.esri.arcgis.version.IArcGISVersionProxy.<init>(Unknown Source)
at com.esri.arcgis.version.VersionManager.<init>(Unknown Source)
at com.esri.arcgis.version.VersionManager.<init>(Unknown Source)
at com.esri.arcgis.system.EngineInitializer.setVersionAndInitialize(Unkn
own Source)
at com.esri.arcgis.system.EngineInitializer.initializeVisualBeans(Unknow
n Source)
at Interface.SondageOCP.main(SondageOCP.java:282)
at Deploy.Bootstrapper.main(Bootstrapper.java:13)
{}
formatting button to indent all your code for legibility.