A similar question has already been answered for Windows, but I could not find out how to achieve the same on Linux.
I want to deepen my knowledge in JNI. I already got JNI projects working with JNI_CreateJavaVM
, creating a new JVM from within the native application.
But this time I would like to not create the JVM within the native application (i.e., not using JNI_CreateJavaVM
), but to attach to an already running one (i.e., using AttachCurrentThread
on a VM that has been started before the native application by some java myApplication
call).
Is there a way on Linux how to achieve this? I need to get a JavaVM
object of the running JVM. I tried to use JNI_GetCreatedJavaVMs
, but this does not return any JVMs (I think this method only returns VMs created by the current process, e.g., by using JNI_CreateJavaVM
, and not all VMs that are running on the system)