如何使用Jconsole监控Java程序? [英] How to monitor a Java program using Jconsole?
问题描述
我编写了一个程序,使用2个线程从1到200打印数字。
现在我想使用JConsole监控这个程序。
基本上我想学习如何使用JConsole来监控应用程序。
我搜索谷歌但却没有找到有用的东西。
我怎样才能做到这一点?
当我开始 bin文件夹中的jconsole.exe
。它要求输入主机名和端口号。
在我的情况下,我猜没有。
有人可以指导吗。
假设你有一个班级测试
在包 p1
下,你有代码使用2个线程(你想要监控)打印1到200的数字。
所以要使用 也是出于此目的。
I have written a program to print number from 1 to 200 using 2 threads.
Now I want to monitor this program using JConsole.
Basically I want to learn how to use JConsole for monitoring an application.
I searched google but couldn't find something useful.
How I can achieve this?
When I started jconsole.exe
in bin folder. It asks for hostname and port number.
Here in my case, there is none, I guess.
Can somebody guide.
Let's say you have a class Test
under package p1
where you have the code to print numbers from 1 to 200 using 2 threads(which you want to monitor).
So to use jconsole for monitoring your application, you would need to compile and execute your code first and while your code is executing...
Start
->Run
->jconsole.exe
and hit/pressEnter
Select the application which you want to monitor and then click
Connect
.
Alternatively,you can use VisualVM for this purpose as well.
这篇关于如何使用Jconsole监控Java程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!