Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7411433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:23:10+00:00 2026-05-29T06:23:10+00:00

tl;dr: C++ plugin needs to call Java .jar library. How to deploy this to

  • 0

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).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:23:11+00:00Added an answer on May 29, 2026 at 6:23 am

    A possible solution for Windows only.

    Build the QT plugin using the delayed DLL load feature

    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)

    Provide a mechanism to inform the QT plugin of what JRE to use

    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:

    • DANQT_32_JRE_HOME=C:\Program Files (x86)\Java\jre7 (for 32-bit JRE)
    • DANQT_64_JRE_HOME=C:\Program Files\Java\jre7 (for 64-bit JRE)

    QT Plugin Modify its PATH

    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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have plugin system in my Java application. Is it possible to load JAR
Im building plugin to FF and Chrome , this plugin needs to call API
I have written a NPAPI plugin in C which needs to call the NPN_Invoke
I am developing a plugin for eclipse. In this plugin I need to be
I need to add Plugin support to a Java Swing App (like in Eclipse).
I need to develop a generic jQuery-based search plugin for the ASP.NET MVC application
We are extending our java application to support plugins. Part of that includes keeping
My application allows users to write plugins (implementing IPlugin) that they can instantiate at
I am attempting to make a game using java, and I need a plugin
I'm developing an eclipse plugin and I need to, programmatically, instantiate a Java Editor.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.