arcengine java,arcengine java :Could not load native libraries 问题解决

该博客讨论了在将ArcGIS Engine的初始化代码部署到Tomcat服务器时遇到的'Could not load native libraries'错误。作者提供了一个解决方法,涉及检查ArcGIS Engine的安装路径,确保arcobjects.jar文件存在于指定位置,并将其添加到系统类加载器中,从而成功初始化许可。
摘要由CSDN通过智能技术生成

EngineInitializer.initializeEngine();

try {

com.esri.arcgis.system.AoInitialize ao = new com.esri.arcgis.system.AoInitialize();

if (ao.isProductCodeAvailable(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB) == com.esri.arcgis.system.esriLicenseStatus.esriLicenseAvailable)

ao.initialize(com.esri.arcgis.system.esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB);

} catch (Exception e) {

e.printStackTrace();

}

一般的初始化license如上代码 在本地运行一切ok 但是放到 tomcat上做服务时 便出现Could not load native libraries 的问题

通过网上查询发现了如下的解决方法 加在上面语句的前面  测试通过

public static void InitLiscense() {

// Get the ArcGIS Engine runtime, if it is available

String arcObjectsHome = "E:\\Program Files\\ArcGIS\\Desktop10.0\\";

// If no runtime is available, exit application gracefully

if (arcObjectsHome == null) {

System.err

.println("You must have the ArcGIS Engine Runtime installed in order to execute this application.");

System.err

.println("Install the product above, then re-run this application.");

System.err.println("Exiting execution of this application...");

System.exit(-1);

}

// 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 application...");

System.exit(-1);

}

// Helps load classes and resources from a search path of URLs

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[] { 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 application...");

System.exit(-1);

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值