Last active
          May 7, 2022 16:30 
        
      - 
      
 - 
        
Save m-szalik/93c559bf2ad964078e1e to your computer and use it in GitHub Desktop.  
    How to enable remote JMX access
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | java -jar yourApp.jar [JVM_OPTIONS] | |
| For local host access only JVM_OPTIONS are: | |
| -Dcom.sun.management.jmxremote | |
| -Dcom.sun.management.jmxremote.port=9010 | |
| -Dcom.sun.management.jmxremote.host=127.0.0.1 | |
| -Dcom.sun.management.jmxremote.local.only=true | |
| -Dcom.sun.management.jmxremote.authenticate=false | |
| -Dcom.sun.management.jmxremote.ssl=false | |
| For full remote access JVM_OPTIONS are: | |
| -Dcom.sun.management.jmxremote | |
| -Dcom.sun.management.jmxremote.port=9010 | |
| -Dcom.sun.management.jmxremote.local.only=false | |
| -Dcom.sun.management.jmxremote.authenticate=false | |
| -Dcom.sun.management.jmxremote.ssl=false | |
| Prefer IPv4 over IPv6: | |
| -Djava.net.preferIPv4Stack=true | |
| Example: | |
| java -jar MyJar.jar -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=9010 -Dcom.sun.management.jmxremote.local.only=true -Dcom.sun.management.jmxremote.host=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.net.preferIPv4Stack=true | |
| More: | |
| http://java.sun.com/javase/6/docs/technotes/guides/management/agent.html | |
For remote connections you might also wanna setup the " -Djava.rmi.server.hostname=xxxxx", otherwise, it'll use the machines primary IP, which doesn't work over a tunnelled or NATed connection. Full details at: https://docs.oracle.com/javase/8/docs/technotes/guides/rmi/javarmiproperties.html
For remote connections you might also wanna setup the " -Djava.rmi.server.hostname=xxxxx"
👍
Do we need to set the below property when using Java 8 ?
Dcom.sun.management.jmxremote.local.only=true
As per the below thread, it seems, this is ineffective
https://support.oracle.com/knowledge/Middleware/1641501_1.html
I've explained this in detail: Remote monitoring with visualvm and JMX
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
may need to set "-Dcom.sun.management.jmxremote.rmi.port" as well on remote access, as RMI opens an arbitrary port unless its set (which doesn't play nice with firewall). you can set it to the same port.