[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 . ; \
fi
echo ""
if [ -f ".libs/libgdaljni.dylib" ] ; then \
cp .libs/*.dylib . ; \
fi
ant
Buildfile: /opt/gdal/gdal-2.1.3/swig/java/build.xml

init:
     [echo] version = 2.1.3

compile:
    [javac] Compiling 48 source files to
/opt/gdal/gdal-2.1.3/swig/java/build/classes
    [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

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

compile_tests:
     [echo] compilation of tests complete

all:
BUILD SUCCESSFUL

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]
it.geosolutions.imageio.gdalframework.GDALUtilities.isDriverAvailable
Failed to get the specified GDAL Driver: ECW
Cause: java.lang.UnsatisfiedLinkError:
org.gdal.gdal.gdalJNI.SWIGDriverUpcast(J)J
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

regards
p

[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