Using JNI without having to add jvm.dll path inside Environment Variables (User or System)

sValentin 41 Reputation points
2023-01-26T07:34:19.5333333+00:00

In order to use JNI, you have to add inside Environment Variables (User or System) the path to were jvm.dll is located. You have a few ways to do that, but it is possible. But, is there a way to not have to add the path inside Environment Variables and instead when you call the function to create a VM from C++ to tell it where it is located via JavaVMInitArgs, or maybe JavaVMOption, or in any other way, but like I said without having to add the path in Environment Variables?

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,453 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.

    1 deleted comment

    Comments have been turned off. Learn more

  2. sValentin 41 Reputation points
    2023-01-27T07:24:54.4+00:00

    I'm going to stick with the way I have now which is to add automatically what I need into User Path (as this doesn't require admin as System Path does), and change that value in case the location is changed because of user action.

    It would have been nice to skip that process of having to add a variable into PATH, but as I already have something that works, I'll stick with that and continue the project, and maybe when it is finished I'll take another look at this.

    Thank you all for all of your suggestions!

    As a note, to skip having to add a variable to the PATH, can be done using CreateProcessW. I didn't got to a point where the code would work due to my lack of C++ knowledge. I'll come back to this when the project is done.