[Gdal-dev] Java SWIG bindings

Collins, Benjamin collinsb at mitre.org
Fri Feb 3 10:16:30 EST 2006


In a preemptive move against any questions about how to use the
bindings, I will give these short directions:

0.5.  Make sure that swig/java/java.opt points to your java (JDK)
installation.

1.  Compile the SWIG wrappers into the C/C++ files and Java files.  The
result will be four C/C++ sources (which link between a JNI interface
and the GDAL/OGR DLL) and a number of Java source files in the
org/gdal/* directories that have a Plain Old Java Oject (POJO)
structure that calls into the JNI code.  This is already done in the
source tree since there is no binary code generation, just source
generation.

2.  Compile the C/C++ files into DLLs and the Java source files to a
jar.  This can be done by going into the swig/java directory and
calling 'make build' on GNU platforms (including cygwin) or running
'nmake -f makefile.vc' on MS platforms.  If the jar is not built for
you, run 'ant' and the java sources should be compiled into gdal.jar.
Now you have
 - .libs/lib*jni.so
 - gdal.jar

3.  Import what you need of gdal.jar into your source and go!  An
example is in the apps directory and is called gdalinfo.java.  Here's
how to get it running:
 - Go into the apps directory.
 - Compile with 'javac -classpath ../gdal.jar gdalinfo.java'
 - Run with 'java -cp ../gdal.jar -Djava.library.path=../.libs/
gdalinfo <filename>'


That's it!
--
Ben Collins


-----Original Message-----
From: gdal-dev-bounces at lists.maptools.org
[mailto:gdal-dev-bounces at lists.maptools.org] On Behalf Of Collins,
Benjamin
Sent: Thursday, February 02, 2006 4:39 PM
To: gdal-dev at lists.maptools.org
Subject: [Gdal-dev] Java SWIG bindings

To All,

I have added support for Java in the SWIG bindings section of the code.
As this is a first commit of some code, I would appreciate anyone who
could test it out!

Some notes:
The build process works on the MS box and the Linux box that I have
access to, but these two machines represent a very small portion of
possible platforms, so I anticipate some time to get the kinks worked
out of the build process.

I have used the most Java-natural classes where I could.  That means
exchanging Hashtable, Vector, and Color objects among other things.  If
you notice any incompatibilities with the intent of GDAL and my
choices, they can be changed.

I have used NIO Direct ByteBuffers for the main part of the data
exchange in the RasterIO.  Please note that I think this is by far the
fastest way to exchange data, but I'm open to other's suggestions.  If
you're using something older than Java 1.4 these will not work!

I have one test application in the apps directory, and I have another
to add soon that demonstrates the reading of raster data.


--
Ben Collins

_______________________________________________
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