Changes between Version 10 and Version 11 of GdalOgrInJavaBuildInstructions


Ignore:
Timestamp:
Nov 27, 2023, 5:14:43 AM (5 months ago)
Author:
Even Rouault
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GdalOgrInJavaBuildInstructions

    v10 v11  
    1 
    2 = Build Instructions for GDAL/OGR In Java (Windows) =
    3 
    4 Note that [http://osgeo4w.osgeo.org OSGeo4W] includes a [http://trac.osgeo.org/osgeo4w/wiki/pkg-gdal-java gdal-java] package and a Java runtime making it fairly easily to build local Java applications using GDAL.  The following instructions describe how to build the Java bindings from scratch.
    5 
    6 == Install SWIG ==
    7 
    8 [http://www.swig.org/download.html]
    9 
    10 Install an appropriate version of SWIG for windows.  GDAL/OGR's Java bindings correct operation are fairly sensitive to the version of SWIG used.  Version 1.3.39 is appropriate for GDAL/OGR 1.8.0.  A Windows version with a pre-built executable is available, so compiling isn't necessary.
    11 
    12 OSGeo4W has a "swig" package which will install a suitable version of swig in C:\OSGeo4W\apps\swigwin.
    13 
    14 == Install the latest version of the Java SE Development Kit ==
    15 
    16 Make sure you are getting the "JDK", not just the runtime environment.  The "SE" (standard edition?) is fine, no need for "EE" (enterprise edition).
    17 
    18 [http://www.oracle.com/technetwork/java/javase/downloads/index.html]
    19 
    20 
    21 == Install Apache Ant ==
    22 
    23 [http://ant.apache.org/bindownload.cgi]
    24 
    25 Binary distributions are available, so compiling isn't necessary.
    26 
    27 == Download and Configure GDAL ==
    28 
    29 [http://trac.osgeo.org/gdal/wiki/DownloadSource]
    30 
    31 Follow normal steps to configure GDAL by modifying <''gdal-dir''>\nmake.opt.  In addition to normal steps ensure that the SWIG, JAVA and ANT related definitions are set appropriately.   Perhaps something like:
    32 
    33 {{{
    34 JAVA_HOME = "C:\Program Files\Java\jdk1.6.0_23"
    35 JAVADOC=$(JAVA_HOME)/bin/javadoc
    36 JAVAC=$(JAVA_HOME)/bin/javac
    37 JAVA=$(JAVA_HOME)/bin/java
    38 JAR=$(JAVA_HOME)/bin/jar
    39 JAVA_INCLUDE=-I$(JAVA_HOME)\include -I$(JAVA_HOME)\include\win32
    40 
    41 ANT_HOME=C:\apache-ant-1.8.2
    42 
    43 SWIG=C:\OSGeo4W\apps\swigwin\swig.exe
    44 }}}
    45 
    46 == Compile GDAL ==
    47 
    48 See BuildingOnWindows for details on configuring and building GDAL on windows.
    49 
    50 {{{
    51 nmake /f makefile.vc
    52 }}}
    53 
    54 == Build Java Bindings ==
    55 
    56 This step will run SWIG to generate the Java bindings (it will use nmake/cl.exe to build the C++ side of the Java bindings and ANT/javac to compile the java side of the bindings).
    57 
    58 {{{
    59 cd swig
    60 nmake /f makefile.vc java
    61 }}}
    62 
    63 The result, in the gdal/swig/java directory, should be the following files: gdal.jar, gdalconstjni.dll, gdaljni.dll, ogrjni.dll and osrjni.dll.
    64 
    65 == Test Sample Application ==
    66 
    67 First, ensure that java.exe and javac.exe are available in your path and that any DLLs on which GDAL depends are in your path.
    68 
    69 {{{
    70 cd swig\java\apps
    71 copy ..\..\..\*.dll
    72 copy ..\*.dll
    73 javac -classpath ..\gdal.jar;. gdalinfo.java
    74 java -classpath ..\gdal.jar;. gdalinfo
    75 }}}
    76 
    77 You should get a usage message, or add a filename to the end of the last command to see a gdalinfo style report on the file.
    78 
    79 == Install components ==
    80 
    81 The jni dll's can be installed somewhere appropriate, often wherever the main GDAL DLL (ie gdal18.dll) goes.   
    82 
    83 The gdal.jar will need to be in the class path.
    84 
    85 
    86 == CLASSPATH ==
    87 
    88 It may be desirable to modify the CLASSPATH globally.  This can be done like this:
    89 
    90 a. In the Control Panel, open up System. Switch to the Advanced tab and click on Environmental Variables.
    91 
    92 b. In the System Variables pane, look for CLASSPATH. If it exists, click on "Edit" and ensure that "." and "..\gdal.jar" are included. Individual items are separated by colons. If CLASSPATH does not exist, click on "New" and add CLASSPATH with the same two locations.
    93 
     1See See https://gdal.org/api/java/index.html