[gdal-dev] GDAL java binding in windows.

maven apache apachemaven0 at gmail.com
Thu Nov 5 06:29:36 PST 2020


Hi:
I tried to use gdal with java in window 10,and I installed gdal from the
pre-built binary from “https://www.gisinternals.com/“.
Then I set the required environment variables by following this topic:
https://docs.geoserver.org/stable/en/user/data/raster/gdal.html
After that, I tried to validate this in jshell:
First check the environment variables are set properly:

C:\Users\xx>echo %Path%
C:\Program Files (x86)\NetSarang\Xshell
6\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program
Files (x86)\Windows Kits\8.1\Windows Performance
Toolkit\;C:\WINDOWS\System32\OpenSSH\;C:\Go\bin;C:\Program
Files\Pandoc\;C:\Program Files (x86)\Yarn\bin\;C:\Program
Files\Git\cmd;C:\Users\xx\AppData\Local\Microsoft\WindowsApps;D:\program\jdk_jre\jdk\bin;C:\Users\xx\AppData\Local\Programs\Fiddler;C:\Program
Files\QGIS 2.18\bin;C:\Python27;%GOPATH%\bin;C:\Users\xx\AppData\Local\Microsoft\WindowsApps;C:\Program
Files\Bandizip\;C:\Program
Files\Docker\Docker\resources\bin;C:\Users\xx\go\bin;C:\Program
Files\Docker Toolbox;C:\Users\xx\AppData\Local\Yarn\bin;D:\program\gdal-3.2-dev-mapserver\bin\gdal\java;D:\program\gdal-3.2-dev-mapserver\bin;

C:\Users\xx>echo %PROJ_LIB%
D:\program\gdal-3.2-dev-mapserver\proj6\share

C:\Users\xx>echo %GDAL_DATA%
D:\program\gdal-3.2-dev-mapserver\bin\gdal-data

Then tried to load the jni library:

C:\Users\xx>jshell
|  Welcome to JShell -- Version 11.0.8
|  For an introduction type: /help intro

jshell> System.loadLibrary("gdalalljni")
|  Exception java.lang.UnsatisfiedLinkError:
D:\program\gdal-3.2-dev-mapserver\bin\gdal\java\gdalalljni.dll: The
specified procedure could not be found
|        at ClassLoader$NativeLibrary.load0 (Native Method)
|        at ClassLoader$NativeLibrary.load (ClassLoader.java:2430)
|        at ClassLoader$NativeLibrary.loadLibrary (ClassLoader.java:2487)
|        at ClassLoader.loadLibrary0 (ClassLoader.java:2684)
|        at ClassLoader.loadLibrary (ClassLoader.java:2649)
|        at Runtime.loadLibrary0 (Runtime.java:827)
|        at System.loadLibrary (System.java:1871)
|        at (#1:1)

jshell> /exit
|  Goodbye

As shown, the jni library can not be loaded correctly.

Then reset the environment variables again in the terminal:

C:\Users\xx>SET
PATH=%PATH%;D:\program\gdal-3.2-dev-mapserver\bin\;D:\program\gdal-3.2-dev-mapserver\bin\gdal\java;

C:\Users\xx>SET PROJ_LIB=D:\program\gdal-3.2-dev-mapserver\bin\proj6\share;

C:\Users\xx>SET GDAL_DATA=D:\program\gdal-3.2-dev-mapserver\bin\gdal-data;

C:\Users\xx>jshell
|  Welcome to JShell -- Version 11.0.8
|  For an introduction type: /help intro

jshell> System.loadLibrary("gdalalljni")

jshell>

As shown, it worked.

Why do I have to reset the environment variables again ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20201105/f5720ccf/attachment.html>


More information about the gdal-dev mailing list