rmi - How to set JMX remote port system environment parameters through java code for remote monitoring? -


Text after "div class =" itemprop = "text">

I have a program that needs dynamically (ie on run time) to open an available socket and have a JMX Let the agent begin. These JMX parameters are being set in Java code and not through the command line. It works fine after that it needs to be monitored (i.e. issue of jmx command etc.) away via java visual vm

The RMI server in the program is based on the lines out of the agent agent management :

I can summarize this question: How can such command line properties be set by the Java code at the system level, so that using remote profiling To be ??

  -Dcom.sun .management.jmxremote.port = 1234   

If "jmxremote.port" and other parameters are set through the command line Remote monitoring works fine, so goes remote. I am trying to find a way to do this through Java, not through the command line.

The program can not specify the port via the command line because the new available port is runtime

The process requires remote monitoring and it works fine at the local level. If the following parameters are not specified on the command line, then the Java Visual Studio does not connect to the VM process.

  -Dcom.sun.management.jmxremote.port = 1234 -Dcom.sun.management.jmxremote.authenticate = false -Dcom.sun.management.jmxremote.ssl = false -Djava.rmi .server.hostname = 10.0.0.128   

I have tried

  system.setup ("com.sun.management.jmxremote.port", integer .stosting (port));   

Before joining JMXConnectorServer, this is the first job done in the program. Unfortunately this is not recognized. Only run time properties (i.e., given by the command line, the Java Visual VM is recognized for JMX connections).

In addition to this, it has also come that properties can be removed from the Java collection classes, the property "com.sun.management.jmxremote.port ="

  public static void Setenv (map & lt; string; string; newenv) throws exceptions {class [] classes = Collections.class.getDeclaredClasses (); Maps & lt; String, string & gt; Env = System.getenv (); (Class CL: square) {if ("java.util.Collections $ UnmodifiableMap" .equals (cl.getName ()) {field field = cl.getDeclaredField ("meters"); Field.setAccessible (true); Object obj = field.get (env); Maps & lt; String, string & gt; Map = (map & lt; string, string & gt;) obj; //map.clear (); Map.putAll (newenv); }}}   

Any help would be appreciated!

KBC shows North but did not work for me - although I do see I modified was able and resolved to work

  public static string loadJMXAgent (int port) throws IOException, AttachNotSupportedException, AgentLoadException, AgentInitializationException {string name = ManagementFactory.getRuntimeMXBean () getName () .. VirtualMochine VM = VirtualMatchin.etat (name asbestring (0, nameindexoff ('@'))); String lca = vm.getAgentProperties (). GetProperty ("com.sun.management.jmxremote.localConnectorAddress"); If (LCA == faucet) {path P = path. (System.JetProperty ("JavaMom")). Normal (); If (! "JRE" .equals (p.getName (p.getNameCount () - 1) .toString (.toLowerCase ())) {P = p.resolve ("JRE"); } File f = p.resolve ("lib"). Resolution ("management-agent.jar"). ToFile (); If (! F.exists ()) {new IOEception ("Management agent not found"); } String option = string Format ( "com.sun.management.jmxremote.port =% d," + "com.sun.management.jmxremote.authenticate = false," + "com.sun.management.jmxremote.ssl = false", port); Vm.loadAgent (f.getCanonicalPath (), option); Lca = vm.getAgentProperties (). GetProperty ("com.sun.management.jmxremote.localConnectorAddress"); } Vm.detach (); come back; }   

In Iklips it works but it is a different matter to work on the command line - this has been some discussion about, but I'm adding JAVA_HOME / lib / tools.jar got my Classpath problem resolved

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -