Friday 9 February 2018

Java Monitoring Tools - JConsole Secure Connection Failed

Java is a powerful programming language . Today millions of devices run in Java.Everyday millions of developers write java code and every company writes and compiles thousands of code in java for their service clients.

For earlier java developer ,during the course of development they have to deal with the design and the implementation of java techniques which sometimes looks easy but hard to understand the internals of java mechanisms. Java jdk comes with set of monitoring tools that is shipped inside jdk/bin folder e.g jconsole,jvisualvm . Using them needs a bit of understanding and how to utilize those tools. When you have your java program running , u can start jconsole or jvisualvm.  You can select specific java application and start monitoring. However jconsole cannot launch the application and the below error is shown.











Most of the solution available in internet does not fully solve the purpose. Below are the set of configurations needed which will make the monitoring tools work properly.

Step 1 : Write Java program using any IDE of your like and build a jar out of it .

Step 2: start the jar with the below command

java  -Dcom.sun.management.jmxremote.port=9595
         -Dcom.sun.management.jmxremote.ssl=false
         -Dcom.sun.management.jmxremote.authenticate=false
         -Djava.rmi.server.hostname=localhost  -jar  TestProject.jar

Make sure your java programming runs for sometime until the monitoring tool starts the applications. The monitoring tools does take 2 to 3 mins to find all the loaded applications .

Step 3: Go to JDK/bin  installed path and issue the below command

jconsole localhost:9595

After jconsole is opened,just click Insecure connection


jconsole view of the running programs,its memory usage.





















JvisualVM

At this stage, we can also use jvisualvm. Go to JDK/bin path and start jvisualvm.exe. It list all the java loaded applications and clicking on the selected application will display the Thread/Memory/CPU view.


















Note :

All these monitoring tools will properly work when we run the java program with set of java arguments supplied to the program as mentioned in the Step 2.