Geotools "Failed to load the GDAL native libs." 在运行时,在 Eclipse 中正常

Geotools "Failed to load the GDAL native libs." at runtime, OK in Eclipse

我正在尝试 运行 GeoTools ImageLab.java 示例。它在 Eclipse 中运行良好,我按照说明使用 Maven。我正在尝试加载 GeoTIFF。但是,当我使用 Eclipse 构建一个 运行nable jar 文件并从 DOS 命令行构建 运行 时,我得到:

Jun 11, 2018 6:49:57 PM it.geosolutions.imageio.gdalframework.GDALUtilities loadGDAL
WARNING: Failed to load the GDAL native libs. This is not a problem unless you need to use the GDAL plugins: they won't be enabled.
java.lang.UnsatisfiedLinkError: no gdaljni in java.library.path
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:58)
Caused by: java.lang.UnsupportedOperationException: Trying to get a reader from an unknown format.
    at org.geotools.coverage.grid.io.UnknownFormat.getReader(UnknownFormat.java:53)
    at org.geotools.tutorial.raster.ImageLab.displayLayers(ImageLab.java:103)
    at org.geotools.tutorial.raster.ImageLab.getLayersAndDisplay(ImageLab.java:87)
    at org.geotools.tutorial.raster.ImageLab.main(ImageLab.java:61)

JNI 参考让我觉得我需要一个 gdal dll 文件,但如果是这样的话,我很难找到一个。

感谢所有帮助!提前致谢。

如果您正在使用 gt-imageio-ext-gdal module then you will need to make sure that the JVM can see your gdal libraries and that they are the exact version expected by the module. There are detailed instructions on how to install that on the related GeoServer page

但是,对于简单的 GeoTiff,不需要 GDAL,因为它由 gt-geotiff module 处理。

最后,如果您尝试构建单个 jar 应用程序,则应确保您已阅读并理解此 FAQ entry