java -javaagent:./jmx_prometheus_javaagent-0.13.0.jar=9090:config.yaml -jar Main.jar
How can I do it from a program.
I tried these. no luck!!
try{ String nameOfRunningVM = ManagementFactory.getRuntimeMXBean().getName(); String pid = nameOfRunningVM.substring(0, nameOfRunningVM.indexOf('@')); VirtualMachine vm = VirtualMachine.attach(pid); vm.loadAgent("/Users/zop2816/Downloads/jmx_prometheus_javaagent-0.13.0.jar=9090:/Users/zop2816/Downloads/example.java.helloworld-master/config.yaml", null); vm.detach(); }catch (Exception e) { Exception o = e; e.printStackTrace(); }Please help. TIA.