<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p><br>
</p>
<div class="moz-cite-prefix">Le 27/11/2023 à 10:40, Raivo Rebane via
gdal-dev a écrit :<br>
</div>
<blockquote type="cite"
cite="mid:3fc68a1e-853b-49ab-8435-90becd1515af@r-systems.ee">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<p>Hi,</p>
<p>I want to use GDAL for GML parsing with Java.</p>
<p>I made an Eclipse project and got dependency - gdal-3.8.0.</p>
<p>My code compiles fine, but in debuging at line - <span
style="color: rgb(0, 0, 0); white-space: pre;">gdal.</span><span
style="color: rgb(0, 0, 0); font-style: italic; white-space: pre;">AllRegister</span><span
style="color: rgb(0, 0, 0); white-space: pre;">();</span></p>
<div style="background-color:#ffffff;padding:0px 0px 0px 2px;">
<div
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><p
style="margin:0;">I got error : </p><p style="margin:0;">
</p><div style="background-color:#ffffff;padding:0px 0px 0px 2px;"><div
style="color:#000000;background-color:#ffffff;font-family:"Monospace";font-size:10pt;white-space:pre;"><p
style="margin:0;"><span style="color:#ff0000;">Native library load failed.</span></p><p
style="margin:0;"><span style="color:#ff0000;">java.lang.UnsatisfiedLinkError: no gdalalljni in java.library.path: [/home/Raivo/GML/lib]</span></p><p
style="margin:0;"><span style="color:#ff0000;">Exception in thread "main" java.lang.UnsatisfiedLinkError: 'void org.gdal.gdal.gdalJNI.AllRegister()'</span></p><p
style="margin:0;"><span style="color:#ff0000;"> at org.gdal.gdal.gdalJNI.AllRegister(</span><span
style="color:#007aa6;text-decoration:underline;text-decoration-style:solid;">Native Method</span><span
style="color:#ff0000;">)</span></p><p style="margin:0;"><span
style="color:#ff0000;"> at org.gdal.gdal.gdal.AllRegister(</span><span
style="color:#007aa6;text-decoration:underline;text-decoration-style:solid;">gdal.java:712</span><span
style="color:#ff0000;">)</span></p><p style="margin:0;"><span
style="color:#ff0000;"> at My.Parser.Parser.main(</span><span
style="color:#007aa6;text-decoration:underline;text-decoration-style:solid;">Parser.java:16</span><span
style="color:#ff0000;">)</span></p><p style="margin:0;">an in realility <span
style="color:#ff0000;">gdalalljni </span><font color="#2e3436">doesnt exist in my computer.</font></p><p
style="margin:0;"><font color="#2e3436">
</font></p><p style="margin:0;"><font color="#2e3436">So I cloned GDAL sources from git, version 3.9.0, but I didn't find docs how to buil Java binding jar file</font></p></div></div></div>
</div>
</blockquote>
<p>Cf
<a class="moz-txt-link-freetext" href="https://gdal.org/development/building_from_source.html#java-bindings-options">https://gdal.org/development/building_from_source.html#java-bindings-options</a></p>
<p>I've just submitted in <a class="moz-txt-link-freetext" href="https://github.com/OSGeo/gdal/pull/8836">https://github.com/OSGeo/gdal/pull/8836</a>
more detailed instructions:</p>
<p>"""</p>
<p><br>
How to use the bindings<br>
-----------------------<br>
<br>
The result of the build of the Java bindings will be both a
:file:`gdal.jar`<br>
and a companion :file:`libgdalalljni.so` /
:file:`libgdalalljni.dylib` /<br>
:file:`gdalalljni.dll` native library. To limit potential
compatibility problems,<br>
you should ensure that gdal.jar and gdalalljni come from the same
GDAL sources.<br>
<br>
The native gdalalljni library, as well as the core libgdal library
(and its<br>
dependencies) should be accessible through the mechanism of the
operating<br>
system to locate shared libraries.<br>
Typically on Linux, this means that the path to those libraries
should be set<br>
in the ``LD_LIBRARY_PATH`` environment variable (or in
:file:`/etc/ld.so.conf`).<br>
On MacOSX, it should be in the ``DYLD_LIBRARY_PATH`` environment
variable.<br>
And on Windows, in the ``PATH`` environment variable.<br>
<br>
For example, to test on Linux that the bindings are working, you
can lanch,<br>
from the build directory:<br>
<br>
::<br>
<br>
export LD_LIBRARY_PATH=$PWD:$PWD/swig/java:$LD_LIBRARY_PATH<br>
java -classpath
$PWD/swig/java/gdal.jar:$PWD/swig/java/build/apps gdalinfo<br>
<br>
On Windows:<br>
<br>
::<br>
<br>
set PATH=%CD%;%CD%\swig\java;%PATH%<br>
java -classpath
%CD%\swig\java\gdal.jar;%CD%\swig\java\build\apps gdalinfo<br>
</p>
<p>"""<br>
</p>
<p>Even</p>
<span style="white-space: pre-wrap">
</span>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>