It really comes down to the tool you're using, and they provide different solutions. Quite often, they will listen on a port in the server-side JVM, which the tool attaches tool. Some tools touch the classes to add extra information, some can profile the application without modification.
I've used JProfiler in the past, which was very good. It is a commercial tool, though. So there is a cost. I've used NetBean's profiler as well with good results. It is a free application, so there's no cost there. JavaMelody looks good as well as suggested by Piotr, although I don't have any personal experience with that.
You'll just need to grab a tool and try it out.