tl;dr: C++ plugin needs to call Java .jar library. How to deploy this to users without too much headache?
I'm writing a Qt plugin for a Qt application. The plugin needs to make calls to an existing Java library. This needs to work cross-platform (Win, Mac, Linux) and architecture (32-bit and 64-bit Intel, no PPC).
I got a simple "hello world" JNI example compiling and running. I updated the CMake script to "find_package(JNI REQUIRED)" etc. so it compiles against the jni.h header and dynamically links against the JVM library.
On Windows at least, CMake does a good job of finding the right JVM to use at compile time. It's finding the right JRE (jvm.dll, etc.) at runtime that concerns me, since I have less control over user's computers.
How will it work when I send the plugin to my users? They will need a JRE installed for the proper architecture. But that doesn't mean the JRE lib directory(ies) will be in their path. If they're not, the plugin just bails out and doesn't load.
It also seems troublesome that on Windows, the 64-bit JDK installed jvm.dll to:
C:\Program Files\Java\jre7\bin\server\jvm.dll
But the 32-bit JDK installed it to:
C:\Program Files (x86)\Java\jre7\bin\client\jvm.dll
I understand the PF vs. PFx86 difference, but the server/client thing I don't get. Are these actually different JREs?
Will it work if I have compiled/linked against one JRE version and the user has a different version?
I assume this will all be easier on Linux/Mac, but I haven't gotten that far yet.
Any help is appreciated. I'm not tied to using JNI, but can't afford a $2000 compiler to turn the Java into a native code library (not that I have the source anyhow), and I hear gcj may not be up to the task (and probably wouldn't help much on Windows).