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

Kedar Deshpande kedardeshpande87 at gmail.com
Mon Jun 11 09:48:58 PDT 2012


I am still getting the same exception. Even export env variable is not
working.
The entire exception I am getting is :

kdeshpan.desktop% java -classpath `pwd`/gdal.jar:`pwd`:`pwd`/apps
apps/TestClass
Native library load failed.
java.lang.UnsatisfiedLinkError:
/rhel5pdi/home/kdeshpan/gdal_java/swig/java/libogrjni.so:
/rhel5pdi/home/kdeshpan/gdal_java/swig/java/libogrjni.so: wrong ELF class:
ELFCLASS64 (Possible cause: architecture word width mismatch)
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)

What am I missing? Can someone please let me know all the steps for using
this library with Java bindings.

Thanks,
Kedar

On Fri, Jun 8, 2012 at 8:25 PM, Chaitanya kumar CH
<chaitanya.ch at gmail.com>wrote:

> 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/20120611/b5162e84/attachment-0001.html>


More information about the gdal-dev mailing list