Hey,
I am trying to write a Java application that uses GDAL on Windows 7. I am using the Java bindings of GDAL together with the gdal DLLs from the GDAL download page.
I hope you are familiar with the distributions I'm using:
GDAL DLLs:
imageio-ext-1.0.5-windows32-dlls/*
GDAL Java bindings:
imageio-ext-1.0.8-libraries/*
I have copied all the DLLs into my jre/bin directory of my Java Runtime environment.
Everything works fine if I run the program via the Eclilpse run configuration. GDAL libraries are properly loaded, and are able to read a shapefile that my program opens and display its contents.
My program starts like this:
<b>
package mapillustrator;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import mapillustrator.controller.Controller;
import mapillustrator.view.MainWindow;
import org.gdal.ogr.ogr;
/*
* To change this template, choose Tools | Templates and open the template in
* the editor.
*/
/**
*
* @author marvin
*/
public class MapIllustrator {
        public static Controller controller;
        public static MainWindow mainWindow;
        public static void main(String[] args) throws Exception {
                try {
                        System.loadLibrary("gdal14");
                        ogr.RegisterAll();
                        controller = new Controller(args[0]);
                        mainWindow = new MainWindow(null, true);
                } catch (Exception e) {
                        JOptionPane.showMessageDialog(new JLabel(), e.getMessage());
                        e.printStackTrace();
                }
        }
}</b>
So, as I said, all this works fine.
However, I now want to have the main method launched via a python script for some reason, so here's my python script (the script is located at <b>"C:\Program Files\Inkscape\share\extensions"</b>):
<b>import os, sys, subprocess, time
dir = os.getcwd().replace("\\", "/") + "/share/extensions/MapIllustrator/"
libdir = dir + "lib/"
subprocess.Popen("java -verbose -classpath \".;C:/Program Files/Java/jre6/lib/ext/QTJava.zip;" + dir + "build/classes;" + libdir + "*;" + libdir + "SuperCSV-1.52/*;" + libdir + "batik-1.7/*;" + libdir + "batik-1.7/lib/*;" + libdir + "batik-1.7/extensions/*;" + libdir + "imageio-ext-1.0.8-libraries/*;" + "\" mapillustrator.MapIllustrator \"" + sys.argv[-1] + "\"", stdout=True)</b>
But everytime I launch my application via the script I get an UnsatisfiedLinkError of the kind
<b>
"gdal14.dll: Can't find dependent libraries"</b>
I'm really wondering why I am not getting this error if I launch my program via Eclipse. No such error occurs there and GDAL manages to load all the libraries and does not complain about any dependencies.
Obviously, the gdal14.dll is found. I'm using the JDK1.6.0.22 with Eclipse. Its JRE is also configured as the default JRE in my windows registry:
<b>C:\Program Files\Java\jdk1.6.0_21\jre</b>
As I said, I have also copied all files from the <b>imageio-ext-1.0.5-windows32-dlls/*</b> into the <b>"C:\Program Files\Java\jdk1.6.0_21\jre\bin"</b>. I have also tried copying them to <b>"C:\Program Files\Java\jdk1.6.0_21\bin"</b> instead. The all Java bindings for GDAL are also included in the Java classpath in my Eclipse project settings. As you can see in the Python script, I am also doing that above.
So obviously, there has to be a difference in how Eclipse launches my Java program and in how the python script does. I don't see any other explanation, and I also don't know what on earth Eclipse does different to have it run without a problem. There isn't a single argument set in my run configuration. I don't know how Eclipse actually transfers the classpath arguments of the project settings into the program launch (probably adds the -classpath <...> argument on its own), but other than that I'd really like to know what I am doing wrong.
The only difference between running from Eclipse and running via my python script seems to be that my python script is that both are calling java from a different current working directory: The project home in Eclipse VS "C:\Program Files\Inkscape" in the script. The script is being launched as an Inkscape extension. I don't know why Inkscape sets the CWD to "C:\Program Files\Inkscape", although it is located at <b>"C:\Program Files\Inkscape\share\extensions"</b>
<br><hr align="left" width="300">
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/UnsatisfiedLinkError-with-gdal14-tp5759024p5759024.html">UnsatisfiedLinkError with gdal14</a><br>
Sent from the <a href="http://osgeo-org.1803224.n2.nabble.com/GDAL-Dev-f2022644.html">GDAL - Dev mailing list archive</a> at Nabble.com.<br>