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
相关推荐
Derek_Smart13 小时前
从一次 OOM 事故说起:打造生产级的 JVM 健康检查组件
java·jvm·spring boot
NE_STOP13 小时前
MyBatis-mybatis入门与增删改查
java
孟陬17 小时前
国外技术周刊 #1:Paul Graham 重新分享最受欢迎的文章《创作者的品味》、本周被划线最多 YouTube《如何在 19 分钟内学会 AI》、为何我不
java·前端·后端
想用offer打牌17 小时前
一站式了解四种限流算法
java·后端·go
华仔啊17 小时前
Java 开发千万别给布尔变量加 is 前缀!很容易背锅
java
也些宝18 小时前
Java单例模式:饿汉、懒汉、DCL三种实现及最佳实践
java
Nyarlathotep011319 小时前
SpringBoot Starter的用法以及原理
java·spring boot
wuwen519 小时前
WebFlux + Lettuce Reactive 中 SkyWalking 链路上下文丢失的修复实践
java
SimonKing19 小时前
GitHub 10万星的OpenCode,正在悄悄改变我们的工作流
java·后端·程序员