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 applica
A possible solution for Windows only.
See DELAYLOAD on how to do this but it is just adding /DELAYLOAD:jvm.dll
and Delayimp.lib
to the linker command. It means that the jvm.dll
will not be loaded when the QT plugin is loaded but at the point it is required (note it does not require using LoadLibrary()
and GetProcAddress()
). (I don't know if there is a similar feature on Linux or Mac)
This could be either a registry value, a configuration file or an environment variable specifically for the plugin (definitely not environment variables JAVA_HOME
or JRE_HOME
that other applications may depend on). Example environment variables:
Before the QT plugin invokes any functions dependent on the JRE it modifies its PATH
environment variable by inserting, for example, %DANQT_32_JRE_HOME%\bin\server;%DANQT_32_JRE_HOME%\bin\client;
at the start of the value for PATH
. This means when the QT plugin performs its first action that requires the JRE it will be loaded from the inserted directories. (Different environment variables for 64-bit). As for bin\server
and bin\client
my understanding is that these are essentially the same but the server
performs more during initialisation for runtime performance reasons.
I am unsure of compatibility if the QT plugin was built against JRE 6 and JRE 7 was installed. If there are compatibility issues then make it a prerequisite installation requirement or, if permitted (I am unsure of legalities), ship the jvm.dll
with the QT plugin.