Opened 14 years ago

Closed 14 years ago

#3598 closed defect (invalid)

Unable to run compiled GDALtest with Java

Reported by: raptorland Owned by: Even Rouault
Priority: normal Milestone: 1.7.2
Component: JavaBindings Version: 1.7.2
Severity: normal Keywords:
Cc:

Description

I have successfully compiled and built the Java bindings of GDAL 1.7.2 using the instructions at:

http://trac.osgeo.org/gdal/wiki/GdalOgrInJavaBuildInstructions

and using SWIG 1.3.38 and GEOS 3.2.2 (which compiles successfully).

I was only able to compile the GDALtest.java in the apps folder. When I try to run GDALtest I receive the following error:

E:\GDAL\gdal-1.7.2\swig\java\apps>java GDALtest GDAL init... Native library load failed. java.lang.UnsatisfiedLinkError: E:\GDAL\gdal-1.7.2\swig\java\apps\gdaljni.dll: Can't find dependent libraries Exception in thread "main" java.lang.UnsatisfiedLinkError: org.gdal.gdal.gdalJNI.AllRegister()V

at org.gdal.gdal.gdalJNI.AllRegister(Native Method) at org.gdal.gdal.gdal.AllRegister(gdal.java:198) at GDALtest.<clinit>(GDALtest.java:62)

I receive the same error if I specify the java.library.path in the java command. I do not know what library the gdaljni.dll requires.

Help is greatly appreciated.

Change History (1)

comment:1 by Even Rouault, 14 years ago

Priority: highnormal
Resolution: invalid
Severity: blockernormal
Status: newclosed

I'm quite sure it is just an issue with your configuration. You must set your classpath so that it points to the gdal.jar and the build\apps subdirectory where GDALtest.class is.

For example, from E:\GDAL\gdal-1.7.2\swig\java :

java -cp "gdal.jar;build\apps" GDALtest

The gdaljni.dll, ogrjni.dll, gdalconstjni.dll and osrjni.dll as well as gdal17.dll and other dependant libraries must be in your path.

http://trac.osgeo.org/gdal/wiki/GdalOgrInJavaBuildInstructions hasn't been updated lately so the mentionned are probably not exactly the good ones (typically the test .class are compiled in build/apps now), but this should work provided that Java can access gdal.jar, the test .class file and the various DLL.

Note: See TracTickets for help on using tickets.