JVM 嵌入到 C 中,不出现在 运行 个程序下

JVM Embedded into C, does not appear under running programs

我有一个 C 程序(在 Solaris SPARC 中工作),它正在创建一个 JVM 并通过 JNI 调用一个 Java 应用程序。

JVM 已创建,java 程序按预期工作,但我没有看到 java 进程使用 ps -ef | grep java 命令。

知道可能是什么原因吗?

@apangin 和@the8472 都是正确的,您不会在任何地方找到 java 进程,使用 JNI_CreateJavaVM 您正在将 JVM 功能嵌入到您的进程中。

我将尝试通过参考文档来证明这一点(JNI 的文档很少,但我会尝试)。

来自JNI Specification

Creating the VM

The JNI_CreateJavaVM() function loads and initializes a Java VM and returns a pointer to the JNI interface pointer. The thread that called JNI_CreateJavaVM() is considered to be the main thread.

下面几行:

The attached thread should have enough stack space to perform a reasonable amount of work.

这证实 JVM 实例存在于调用 JNI 的 createJavaVM 方法的同一上下文中,因此没有外部专用进程。