Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dynamically load jvm.dll from within a dll?

843829Aug 8 2008 — edited Apr 21 2009
Basically I have created a dll which sits between an existing c++ application and a java backend. So the c++ app calls the dll, which calls the java code.

Everything works completely fine as long as I have the jvm.dll in my path (environment variables). The problem is that the jvm.dll path will change depending on the user (this is to be deployed on many machines).


So the question is: is it possible to dynamically load the jvm.dll from within the same dll that is doing all the jni calls?

I have the c++ code to get the path and to load the jvm.dll (below), but this code is never even executed because as soon as the c++ application loads my wrapper dll I get the message:
"This application failed to start because jvm.dll was not found"

	
char jvmPath[MAX_PATH];

if (readJvmPathFromRegistry(jvmPath, sizeof(jvmPath)) != 0)
{
	cout << "  Failed to get JVM path from the registry\n";
}

cout << "  JVM path: " << jvmPath << "\n";

HINSTANCE hLib = NULL;
hLib = LoadLibrary(jvmPath);
Hope someone can help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 19 2009
Added on Aug 8 2008
5 comments
705 views