Skip to content

Instantly share code, notes, and snippets.

@sachin-handiekar
Last active September 19, 2018 09:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachin-handiekar/fbbaa99a7d924d65cc52 to your computer and use it in GitHub Desktop.
Save sachin-handiekar/fbbaa99a7d924d65cc52 to your computer and use it in GitHub Desktop.
Compiling and creating a DLL file for a simple JVMTI example

Compiling the program

gcc -c -o simpleJVMTI.o -I"%JAVA_HOME%\include" -I"%JAVA_HOME%\include\win32"  SimpleJVMTI.c

Creating a DLL file

gcc -shared -o simpleJVMTI.dll  simpleJVMTI.o

Simple Hello World application

public class HelloWorld {
	public static void main(String[] args) {
		System.out.println("I'm inside main()");
	}
}

Running the Java application with the native agent

java -agentpath:C:/path/to/simpleJVMTI.dll HelloWorld

Output :

I'm inside main()
I'm a native Agent....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment