Connecting locally is easy since jvisualvm will just locally look up the running JVM. But for connecting remotely, you will need some more setup.
All the communication relies on JMX and, therefore, you need to set up a remote JMX connection. This relies on what is called a connector (can be seen as a small embedded JMX server). There are multiple protocols available but out of the box; they rely on RMI communications and system properties to be configured.
To add these system properties, the fastest and easiest way is as follows:
-Dcom.sun.management.jmxremote.port=1234-Dcom.sun.management.jmxremote.ssl=false-Dcom.sun.management.jmxremote.authenticate=false
It will enable JMX on port 1234 and disable SSL and security. ...