1

Edit2: Forgot to mention that I am trying to build a 64-bit application.

I need some help here.

For some reason I can't seem to find a way to make this external work and well, before you ask. I've tried calling LoadLibrary:

// (temp)
// Load JVM library since it's being a dork
HINSTANCE hVM = LoadLibraryA("C:\\Program Files\\Java\\jdk1.8.0_172\\jre\\bin\\server\\jvm.dll");
if (hVM == NULL) { ... }

I have every lib folder included in VC++ Directory, I have also tried putting jvm.lib in same dir and just linking it through pragma comment: #pragma comment(lib, "jvm.lib") But nothing seems to do the job. :/ Am I maybe looking at the wrong file to begin with? I've tried others like jawt.lib as well.

Edit: I get the function from #include <jvmti.h> but there is no corresponding .lib or .dll file. And every similar function comes from jvm so if it's not that one, which one is it? I'm lost.

Vellety
  • 7
  • 4
  • Where are you getting this error? I would assume link-time, but you're not linking against any JNI headers/libraries in your code. What are you trying to achieve? – orhtej2 May 07 '18 at 17:29
  • @orhtej2 I simply included the corresponding header file (jvmti.h) and executed the function in a if-check like this: `if (JNI_GetCreatedJavaVMs(&jvm, 1, &jCount) != JNI_OK || jCount == 0) { ... }` Edit: I'm trying to get the JVM environment from a running process basically. – Vellety May 07 '18 at 17:33
  • Perhaps this will help (notice that you should include `jni.h` instead of `jvmti.h`): https://stackoverflow.com/a/25685254/7034621 – orhtej2 May 07 '18 at 17:40
  • @orhtej2 Using `jni.h` gives same results and I have all that set already i'm afraid :/ – Vellety May 07 '18 at 17:48
  • What I wanted you to take out from the link posted is that you need to link against an additional library - `jvm.lib` – orhtej2 May 07 '18 at 17:49
  • @orhtej2 Which I stated that I have done already.. and it does not fix the error. – Vellety May 07 '18 at 17:54

1 Answers1

0

My bad, I thought it worked for both 32-bit and 64-bit applications but seems like it only works on 32-bit applications. (Was using a 32-bit JDK install and in my haste I did not realize that.)

Vellety
  • 7
  • 4