4

I'm trying org.gdal library on Ubuntu.

<dependency>
  <groupId>org.gdal</groupId>
  <artifactId>gdal</artifactId>
  <version>2.3.3</version>
</dependency>

And got runtime error: Native library load failed. java.lang.UnsatisfiedLinkError: no gdalalljni in java.library.path

1) Before this I installed gdal:

sudo apt-get install gdal-bin
sudo apt-get install libgdal-dev

There are no any gdalalljni files installed.

2) export LD_LIBRARY_PATH=/usr/lib which contains files libgdal.a, libgdal.so, libgdal.so.20 libgdal.so.20.3.2 and not contains any gdalalljni

3) export GDAL_DATA=/usr/share/gdal/2.2

4) set VM options -Djava.library.path="/usr/lib/"

I tried some advices such as http://geoexamples.blogspot.com/2012/05/running-gdal-java.html Here is about 1.9 release. I not found swig/java directory in my installation of 2.2.

How to use last releases of gdal in java on Ubuntu?

1 Answer 1

4

1) First, you should download gdal sources (https://trac.osgeo.org/gdal/wiki/DownloadSource). I placed it to $HOME/gdal-version. Select appropriate version. For me 2.4.2 was installed on Ubuntu 18, and 2.2.4 was installed on Ubuntu 16.

2) Install swig, libgeos-dev and proj4:

sudo apt-get install swig
sudo apt-get install libgeos-dev
sudo apt-get install libproj-dev proj-data proj-bin

3) Go to swig/java folder of sources, edit java.opt: set JAVA_HOME var

4) From sources root run:

./configure --with-java --with-proj=/usr/lib/x86_64-linux-gnu/libproj.la

5) From sources root run: make

6) From swig/java run: make

7) Set environments

export GDAL_BIN=<sources-dir>/apps/
export GDAL_DATA=<sources-dir>/data/
export LD_LIBRARY_PATH=<sources-dir>/swig/java/

8) In java project set VM options -Djava.library.path="/swig/java/"

2
  • 1
    I have been struggling with this for days. Is there any official documentation about this? I found this, but it is is only covering the basics: trac.osgeo.org/gdal/wiki/BuildingOnUnix
    – Hans
    Commented Feb 24, 2022 at 8:35
  • 1
    On version 3.5.1 of gdal on Ubuntu I just had to run configure, without the --with-java and without the --with-proj parameters. This is also what the documentation linked by @Hans had recommended. With your extra parameters I was getting an error complaining about a missing proj.h file.
    – Ring
    Commented Jul 7, 2022 at 16:18

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.