[gdal-dev] Building java bindings with GDAL 2.1.3

Paolo Corti pcorti at gmail.com
Thu Apr 27 15:23:57 PDT 2017

Dear list

I am trying to build the Java bindings for GDAL 2.1.3, for Java
1.7.0_80, using SWIG 3.0.8, in Ubuntu 16.04LTS, following these
instructions [1].

The aim is to use the gdal GeoServer plugin with gdal 2.1.3. The
GeoServer I am using is a very old version (2.3) and I don't have the
possibility to upgrade in the near future.

Following the instructions, Java bindings seem to be correctly built:

/opt/gdal/gdal-2.1.3/swig/java$ make
mkdir -p org/gdal/gdal
mkdir -p org/gdal/gdalconst
mkdir -p org/gdal/ogr
mkdir -p org/gdal/osr
if [ -f ".libs/libgdaljni.so" ] ; then \
cp .libs/*.so . ; \
echo ""
if [ -f ".libs/libgdaljni.dylib" ] ; then \
cp .libs/*.dylib . ; \
Buildfile: /opt/gdal/gdal-2.1.3/swig/java/build.xml

     [echo] version = 2.1.3

    [javac] Compiling 48 source files to
    [javac] warning: [options] bootstrap class path not set in
conjunction with -source 1.5
    [javac] Note: Some input files use unchecked or unsafe operations.
    [javac] Note: Recompile with -Xlint:unchecked for details.
    [javac] 1 warning
     [echo] compilation complete

      [jar] Building jar: /opt/gdal/gdal-2.1.3/swig/java/gdal.jar

     [echo] compilation of tests complete


Total time: 2 seconds

I correctly see the built *.so and *.la files and gdal.jar:

$ ls /opt/gdal/gdal-2.1.3/swig/java
... libgdalconstjni.la ... libgdalconstjni.so ... gdal.jar ...

Though, I do not see any .java files in build/apps (as there should be
according to the documentation) but only .class files. So I cannot run
the java gdalinfo test.

Trying to use the geoserver gdal plugin, I am getting this error (GDAL
was correctly built with ECW support):

27-Apr-2017 19:01:43.176 WARNING [localhost-startStop-1]
Failed to get the specified GDAL Driver: ECW
Cause: java.lang.UnsatisfiedLinkError:
This is not a problem unless you need to use the specified GDAL
plugin. It won't be enabled

I am wondering if this could be caused by the SWIG version which I am using?
Any help will be really appreciated


[1] https://trac.osgeo.org/gdal/wiki/GdalOgrInJavaBuildInstructionsUnix

Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti

More information about the gdal-dev mailing list