When I attach JVisualVM to remote JVM through JMX, I see the "Sampler" tab instead of the "Profiler" tab. I know there is a difference between Sampling and Profiling. I'm more interested in Profiling (specifically CPU Profiling).
Is "Profiler" available in JVisualVM for remote JVM at first place? If so, please mention the specific JVM startup flags. If it's not available, what are the alternatives? Please understand that I can't login to remote hosts.
VisualVM does not support remote profiling as you can find in its source code:
boolean supportsProfiling(Application application) {
// Application already being profiled (Startup Profiler)
if (application == getProfiledApplication()) return true;
// Remote profiling is not supported
if (application.getHost() != Host.LOCALHOST) return false;
...
In fact, sampling is a good alternative to an intrumenting profiler if you wish to find CPU-consuming bottlenecks.
Which tool is better depends on your requirement, but the tool discussion is out of the scope of this question, and is off-topic on Stack Overflow.