The jcmd
utility offers multiple diagnostic commands:
https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/tooldescr006.html
Is it possible to have custom commands and handle them in the running JVM?
Something like: jcmd $PID myCmd