Use java.lang.instrument.Instrumentation; for profiling - http://java.dzone.com/articles/java-profiling-under-covers