我为 Java 编写了一个代理,它什么也不做,只是导出两个方法,只是为了检查它是否在 JVM 启动时加载。使用 mingw-w64 4.8.4(使用 JetBrains CLion)构建它。 Windows 7 x64。
JNIEXPORT jint JNICALL
Agent_OnLoad(JavaVM *jvm, char *options, void *reserved){
return JNI_OK;
}
JNIEXPORT void JNICALL
Agent_OnUnload(JavaVM *vm){}
运行时出错
java -agentlib:"C:\JMVAgent\agent.dll"
Error occurred during initialization of VM
Could not find agent library libSampleAgent.dll on the library path,
with error: Can't find dependent libraries
此外,我将 agent.dll 放入 c:\windows\System32 并运行 java w/o agent 完整路径,得到相同的结果。
请帮忙找出我做错了什么
最佳答案
如果您要指定代理库的完整路径,请使用 -agentpath
而不是 -agentlib
。
差异解释here .
关于java - JMVTI :Could not find agent library,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32605996/