[Gdal-dev] using gdal/ogr within java-project
Collins, Benjamin
collinsb at mitre.org
Tue May 30 10:39:19 EDT 2006
Christine,
I would suggest that you set the java.library.path variable when you
start the JVM. That can be done by adding the argument:
-Djava.library.path=<your path to gdal's java libraries>
to the command when you run java. In Eclipse this can be done by
opening the "Arguments" tab in the "Run..." window, and adding that
string into the lower window, called "VM Arguments". This has always
worked for me and my co-workers.
Also, note that, depending on how the *.so files were built, you still
may be dependant on libgdal.so.
--
Ben Collins
>-----Original Message-----
>From: gdal-dev-bounces at lists.maptools.org
>[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of
>Christine Spietz
>Sent: Monday, May 29, 2006 10:45 AM
>To: gdal-dev at lists.maptools.org
>Subject: [Gdal-dev] using gdal/ogr within java-project
>
>Hi folks,
>
>I've finally installed OGR/GDAL1.3.2 with the
>java-swig-bindings on my Suse
>Linux 10.0.
>(GDAL-HOME = /usr/lib/gdal/gdal-1.3.2)
>
>Now I'm trying to use those bindings within my
>Java-Source-Code but first
>Test even fails:
>I've built an Eclipse-Project with the libraries
>- jre system library (java 1.4.2.06)
>- GDAL-Home/swig/java/gdal.jar
>and imported some filesystems especially:
>- GDAL-Home/swig/java/org
>- GDAL-Home/swig/java/apps
>
>In GDAL-Home/swig/java/apps there are 2 "test-applications"
>- gdalinfo.java
>- GDALtest.java
>
>I've tried to run one of those but getting the following error:
>###
>Native library load failed.
>java.lang.UnsatisfiedLinkError: no gdaljni in java.library.path
>Exception in Thread "main" java.lang.UnsatisfiedLinkError: AllRegister
> at org.gdal.gdal.gdalJNI.AllRegister(Native Method)
> ....
>###
>
>So obviously the application is not able to find the gdaljni.
>
>I wrote some little code to discover the error:
>
>###
>//output of the actual java.library.path
>String props = System.getProperty("java.library.path");
>System.out.println("props = "+props);
>//adding the path to the *jni.so-files generated by java-swig
>System.setProperty("java.library.path",props+":/usr/lib/gdal/gd
>al-1.3.2/swig/java/.libs");
>//Error message was "java.lang.UnsatisfiedLinkError: no gdaljni in
>java.library.path"
>//output of the actual gdaljni-Parameter
>String gdalJNI = System.mapLibraryName("gdaljni");
>System.out.println("gdaljni ="+ gdalJNI);
>###
>
>Output of the Code (integrated in main of gdalinfo):
>###
>props =
>/usr/lib/jvm/java-1.2.4-sun-1.2.4.06/jre/lib/i368/client : .... :
>/usr/lib/gdal/gdal-1.3.2/swig/java/.libs
>gdaljni = libgdaljni.so
>Native library load failed.
>java.lang.UnsatisfiedLinkError: no gdaljni in java.library.path
>Exception in Thread "main" java.lang.UnsatisfiedLinkError: AllRegister
> at org.gdal.gdal.gdalJNI.AllRegister(Native Method)
>###
>
>
>Has anybody an idea
>- what I have to do to run gdalinfo.java/GDALtest.java within
>my project?
>- how to use gdal/ogr within a java-project?
>
>
>regards
>
>Christine
>
>_______________________________________________
>Gdal-dev mailing list
>Gdal-dev at lists.maptools.org
>http://lists.maptools.org/mailman/listinfo/gdal-dev
>
More information about the Gdal-dev
mailing list