I have written this small (and brutally inefficient) class and wanted to profile it using the Java VisualVM.
public class Test {
public static void main
Based on Ron's answer was able to improve the result by stopping the JVM right after the start, then activated the profiler, and finally after that continue the excetion (by pressing enter). It's crude.
class Foobar {
/* First line in Class */
static {
try {
System.in.read();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/* .. */
public static void main(..) {
doMagic()
}
}