I am trying to build a postgis importer for mutliple shapefiles. After geotools took orders of magnitude longer than shp2pgsql to import my data, I decided to attempt to use the java bindings to GDAL (gdal.jar) for these purposes in the hopes that it will be much faster than geotools with an added ability to import from file geodatabases.

I built and installed GDAL using the following steps:

cd /usr/local/src/gis
wget http://download.osgeo.org/gdal/gdal-1.9.2.tar.gz
tar -xzvf gdal-1.9.2.tar.gz
cd gdal-1.9.2

./configure \
--with-python \
--with-poppler \
--with-pg \
--with-curl \
--with-geos \
--with-jpeg \
--with-png \
--with-expat \ 
--with-xerces \
--with-java=/usr/lib/jvm/jdk1.7.0 \
--with-jvm-lib=/usr/lib/jvm/jdk1.7.0/jre/lib/amd64/server \
--with-jvm-lib-add-rpath=yes \
--with-mdb=yes \

sudo make install 

cd /usr/local/src/gis/gdal-1.9.2/swig/java
#nano into java.opt  and change JAVA_HOME to /usr/lib/jvm/jdk1.7.0

I then run a test class that uses gdal.jar and add the above location to the library path so that java can find the shared objects:


When I run the code I get the following error:

Native library load failed.
java.lang.UnsatisfiedLinkError: no gdalconstjni in java.library.path
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.gdal.gdalconst.gdalconstJNI.GDT_Unknown_get()I
    at org.gdal.gdalconst.gdalconstJNI.GDT_Unknown_get(Native Method)
    at org.gdal.gdalconst.gdalconstConstants.<clinit>(gdalconstConstants.java:12)
    at elephantshape.TestGDAL.main(TestGDAL.java:22)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:601)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

What else do I need to do to get java to recognize the shared binaries that I have built and get gdal.jar to not explode?

1 Answer 1


Read the "Running something" section of http://trac.osgeo.org/gdal/wiki/GdalOgrInJavaBuildInstructionsUnix, and particularly :

"To deploy you need gdal.jar in your class path, the 4 .so files (libgdalconstjni.so, libgdaljni.so, libogrjni.so and libosrjni.so) and libgdal.so in your shared library path."

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.