I got this working great on Windows -- application loads my plugin (C++, Qt), my plugin does a smart search to find an installed JRE, sets the library search path accordingly, and then calls a function in the JVM which forces the jvm.dll to be loaded at that point. (Previous question: How can I deploy a mixed C++/Java (JNI) application?)
Now I'm trying to get it working on Linux. From what I read, lazy linking/loading was the default, so I thought it would just work.... doesn't seem like it.
I'd like to avoid dlopen()
and dlsym()
, LD_LIBRARY_PATH
, ldconfig
, etc. The idea is that users of this plugin shouldn't have to know how any of that works, they just put the plugin.so in the right place, and when it's loaded, the plugin has the smarts to find the JRE (or tell the user to install a JRE).
Can this be done?
EDIT
Just to be clear... the error I get when the plugin is loaded: "Cannot load library /home/dan/blah/blah/libMyPlugin.so: (libjawt.so: cannot open shared object file: No such file or directory)"
EDIT
If it matters... this needs to work on Ubuntu 10.10 and up, on CentOS 5.4, and OSX 10.6+.
On Ubuntu 10.10, I did apt-get install openjdk-6-jdk
and then to get things to run correctly I had to
export LD_LIBRARY_PATH=
/usr/lib/jvm/java-6-openjdk/jre/lib/i386:
/usr/lib/jvm/java-6-openjdk/jre/lib/i386/client:
/usr/lib/jvm/java-6-openjdk/jre/lib/i386/xawt
(newlines for legibility)
But if someone had a different JDK installed (e.g., Sun's) then the directories would probably differ (?).