ArcGIS Runtime Java SDK初始化报错:Could not find runtime

在使用ArcGIS Runtime Java SDK进行开发时,遇到以下错误信息:

复制代码
Initializing...
Java version : 11.0.26 (Oracle Corporation) x86_64
Exception in thread "main" java.lang.ExceptionInInitializerError
	at com.esri.arcgisruntime.geometry.SpatialReference.<init>(SpatialReference.java:151)
	at com.esri.arcgisruntime.geometry.SpatialReference.create(SpatialReference.java:88)
	at org.example.shp_ram.demo.MemoryShapefileParserWithVFS.<clinit>(MemoryShapefileParserWithVFS.java:29)
Caused by: java.lang.RuntimeException: Could not find runtime in any of:
- A directory specified by calling ArcGISRuntimeEnvironment.setInstallDirectory()
- The current directory /Users/carter/Desktop/firm/gis_study
- A location specified by the environment variable ARCGISRUNTIMESDKJAVA_100_15_0
- Within the ".arcgis" directory in the user's home path /Users/carter/.arcgis
	at com.esri.arcgisruntime.ArcGISRuntimeEnvironment.lambda$getInstallDirectory$0(ArcGISRuntimeEnvironment.java:285)
	at java.base/java.util.Optional.orElseThrow(Optional.java:408)
	at com.esri.arcgisruntime.ArcGISRuntimeEnvironment.getInstallDirectory(ArcGISRuntimeEnvironment.java:281)
	at com.esri.arcgisruntime.ArcGISRuntimeEnvironment.loadNativeLibraries(ArcGISRuntimeEnvironment.java:795)
	at com.esri.arcgisruntime.ArcGISRuntimeEnvironment.initialize(ArcGISRuntimeEnvironment.java:221)
	at com.esri.arcgisruntime.internal.jni.CoreSpatialReference.<clinit>(CoreSpatialReference.java:41)
	... 3 more

报错图片:

这个错误的核心问题是:系统找不到ArcGIS Runtime的本地库文件。

1.问题根源分析

(1)ArcGIS Runtime Java SDK由两部分组成:

(2)Java API - 纯Java代码,通过Maven依赖引入

本地库文件 - 平台相关的本地动态库(Windows的dll、Linux的so、macOS的dylib)

错误提示表明系统在以下位置都找不到本地库文件:

通过代码设置的安装目录

当前工作目录

环境变量指定的目录

用户home目录下的.arcgis文件夹

2.解决方案

在项目目录下执行以下命令

复制代码
mvn dependency:unpack
相关推荐
像我这样帅的人丶你还20 小时前
Java 后端详解(四):分页与搜索
java·javascript·后端
她的男孩20 小时前
数据权限为什么不能只靠注解?Forge 的 Mapper 层 SQL 改写源码拆解
java·后端·架构
tntxia21 小时前
Mybatis的日志输入
java
亦暖筑序1 天前
Java 8老系统Browser Agent实战:三层拦截把AI操作后台变成可审计流程
java·后端·设计模式
用户298698530141 天前
Java 实现 Word 文档加密与权限解除
java·后端
Yeats_Liao1 天前
14:Servlet中的页面跳转-Java Web
java·后端·架构
未秃头的程序猿1 天前
告别"if-else地狱"!Java 21模式匹配,代码优雅了10倍
java·后端·面试
鹤望兰6751 天前
字节跳动国际支付-后端开发-三面面经
java
Flittly1 天前
【AgentScope Java新手村系列】(14)人机交互
java·spring boot·spring
RainCity1 天前
Java Swing 自定义组件库分享(十二)
java·笔记·后端