[gdal-dev] Using Java bindings of GDAL library : UnsatisfiedLinkError

Chaitanya kumar CH chaitanya.ch at gmail.com
Fri Jun 8 20:25:25 PDT 2012


Kedar,

I don't think setenv works at Linux terminal. Use the export command.

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:`pwd`

You should also set GDAL_DATA to the data directory to gdal/data

On Sat, Jun 9, 2012 at 7:24 AM, Kedar Deshpande
<kedardeshpande87 at gmail.com>wrote:

> Hi,
>
> I am writing a simple program to read a shapefile in Java on my linux
> machine using the gdal library's Java bindings.
>
> I followed the steps according to the link
> http://trac.osgeo.org/gdal/wiki/GdalOgrInJavaBuildInstructionsUnix given
> on the GDAL library's site.
>
> In the gdal folder in gdal/swig/java, I made changes in java.opt and the
> ran 'make' command.
> Then I wrote a simple program under /apps folder as :
>
> package apps;
>
> import org.gdal.ogr.DataSource;
> import org.gdal.ogr.ogr;
>
> public class TestClass {
>
> public static void main(String[] args) {
>  ogr.RegisterAll();
> }
> }
>
> and ran it as
>
> javac apps/TestClass.java
> setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:`pwd`
> java -classpath `pwd`/gdal.jar:`pwd`:`pwd`/apps TestClass
>
> but I am getting UnsatisfiedLinkError after running it.
>
> Native library load failed.
> java.lang.UnsatisfiedLinkError: no ogrjni in java.library.path
> Exception in thread "main" java.lang.UnsatisfiedLinkError: org.gdal.ogr.ogrJNI.RegisterAll()V
> 	at org.gdal.ogr.ogrJNI.RegisterAll(Native Method)
> 	at org.gdal.ogr.ogr.RegisterAll(ogr.java:110)
> 	at apps.TestClass.main(TestClass.java:9)
>
>
> Is there anything I am missing in this configuration?
>
> I have the libgdal.la library files in my PATH env variable. (I am running it on RHEL5)
>
> Can some please let me know how do I get rid of this exception and make it link to the library?
>
> Thanks,
>
> Kedar
>
>
>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>



-- 
Best regards,
Chaitanya kumar CH.

+91-9494447584
17.2416N 80.1426E
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20120609/7d1d1bde/attachment.html>


More information about the gdal-dev mailing list