javac -g HelloWorld.java
java HelloWorld
cat simpleJVMTI.c
1 2 3 4 5 6 |
#include #include JNIEXPORT jint JNICALL Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { printf("I'm a native Agent....\n come on javacoder.cn\n"); return JNI_OK; } |
gcc -fPIC -shared -o libsimpleJVMTI.so -I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux simpleJVMTI.c
java -agentpath:/root/testJVMTI/libsimpleJVMTI.so HelloWorld
Posted in: Linux
Comments are closed.