[gdal-dev] Native library load failed while using gdal maven dependency - UnsatisfiedLinkError

Justin Deoliveira jdeolive at gmail.com
Tue Feb 9 08:55:43 PST 2016


Hi,

Have you set the java.library.path system property to the location of the
gdal libraries on the system? The gdal jar doesn’t contain any of the
native libraries, just the java parts.

I’ve found that usually I do need to set LD_LIBRARY_PATH to include the
location of the gdal libraries, and the location of any libraries that it
is linked to.

For example if you I had the native GDAL libraries in /usr/local/lib I
would set up my java IDE as follows:

- Set the environment variable LD_LIBRARY_PATH (linux) or DYLD_LIBRARY_PATH
(osx) to /usr/local/lib
- Add the java system property “-Djava.library.path=/usr/local/lib”

And that usually does the trick for me. Hope that helps.

-Justin

On Tue, Feb 9, 2016 at 9:40 AM ssaniev <ssaniev at gmail.com> wrote:

> Hey guys,
>
> First time GDAL user here.
>
> We are trying to load shapefiles into postgresql DB, and were able to do so
> with GDAL ogr2ogr CLI utility.
> Following cmd works via cmd:
> ogr2ogr -f PostgreSQL PG:"host='hostName' port='5432' user='userName'
> dbname='dbName' password='aPassword'" shapeFileName.shp
>
>
> *Next step is to accomplish this in java with GDAL bindings. *
>
> There is a maven dependency for gdal which we included in our pom.xml:
>                 <dependency>
>                    <groupId>org.gdal</groupId>
>                    <artifactId>gdal</artifactId>
>                    <version>2.0.0</version>
>                 </dependency>
>
>
> *We import and simply want to output the version of gdal in java: *
>
> import org.gdal.gdal.gdal;
>
> public class ShapeFileWorker {
>     public void process(String fileName, String hostAddress) {
>         gdal.VersionInfo()
>     }
> }
>
>
> *While trying to use gdal library in our java class, we are getting the
> following error: *
> java.lang.UnsatisfiedLinkError: no gdaljni in java.library.path
>
>
> The development project is in SPRING, and Eclipse IDE.
>
> After reading many online gdal discussions, I have added GDAL_DATA and
> LD_LIBRARY_PATH variables.
>
> But since we are using gdal maven dependency, we shouldn't need them.
>
> Anyone could point us in the right direction?
>
>
>
> --
> View this message in context:
> http://osgeo-org.1560.x6.nabble.com/Native-library-load-failed-while-using-gdal-maven-dependency-UnsatisfiedLinkError-tp5249728.html
> Sent from the GDAL - Dev mailing list archive at Nabble.com.
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20160209/d3ee22f4/attachment.html>


More information about the gdal-dev mailing list