GDAL Java Bindings – How to Set Up GDAL Java Bindings for Windows with OSGeo4w

gdaljavaosgeo4wwindows 10

I've been searching for ways to use java bindings for GDAL and installed the OSGeo4W packages QGIS, GDAL, and GrassGIS using the "Express Desktop Install" method.

After installing and confirming the GDAL commands functioning in the OSGeo4W Shell, I do not see the gdal-java package and all of its contents that osgeo.org says it should here. The package should include the Java SWIG bindings for GDAL/OGR and osgeo4w\lib\gdal.jar.

I have the following Windows Environment Variables set up:

 GDAL_DATA set to C:\OSGeo4W64\share\gdal 
 GDAL_DRIVER_PATH set to C:\OSGeo4W64\bin\gdalplugins
 appended C:\OSGeo4W64\bin to PATH

Has the gdal-java package depreciated? (considering the web pages have been updated 7-10 years ago) If so, is there another way of installing GDAL Java bindings easily?

Computer specs: Windows 10 x64

Best Answer

From what I have found, the gdal-java package is not included in the OSGeo4W installation. Sadly, there seems to be no easy way to install the bindings. The steps I've followed are found in this stack exchange question: GDAL Java bindings GDAL 2.0.0 in Eclipse

How I got the GDAL Java Bindings working for Windows

  1. Download and install Python 2.7.
  2. Download and install gdal-202-1500-x64-core.msi (release 1500) from gisinternals.com. Version 1500 and 1800 includes the gdal.jar file that is needed in a later step.
  3. Open and edit the following System Environment Variables in Advanced System Properties:

Append to PATH
- C:\Program Files\GDAL
GDAL_DATA
- C:\Program Files\GDAL\gdal-data
GDAL_DRIVER_PATH
- C:\Program Files\GDAL\gdalplugins

  1. Test to see if GDAL is installed by opening Command Prompt and type in:

    gdalinfo --version

  2. Copy and paste the following dlls from C:\Program Files\GDAL into your Java JDK bin folder (example: C:\Program Files\Java\jdk1.8.0_171\bin)

    gdalconstjni.dll
    gdaljni.dll
    ogrjni.dll
    osrjni.dll

  3. Within Netbeans or Eclipse, add the gdal.jar file from C:\Program Files\GDAL\java to your java project library.

AddingJarFileScreenshot

For IntelliJ Idea: File->Project Structure

enter image description here