jprofiler使用

要使用JProfiler我们可以到官方下载软件,然后***直接google下,下载后解压,然后安装

在解压文件夹中找到.install4j中的setup.exe,双击进行安装

jprofiler使用

安装好了之后就有朋友迫不及待的运行软件,有的朋友就会提示:

The JVM could not be started. The maximum heap size (-Xmx) might bo too large or an antivirus  or firewall tool could block the execution.

 

如图:

jprofiler使用

如果出现这个错误,不要着急,我们找到安装目录下的bin文件夹,里面有个jprofiler.vmoptions文件,我们用记事本打开它,编辑里面的-Xmx(默认是768),如图

jprofiler使用

修改完后,再次运行软件。

 

软件跑起来了,有的朋友就马上来查看运行的java程序,这时候出错了,

 

The selected JVM is a client JVM that uses class sharing.

 

如图:

jprofiler使用

或者,有的朋友按照提示,添加 –server运行,这个错误是解决了,可是有可能还会提示找不到类的错误昂,

java.lang.NoClassDefFoundError: com/jprofiler/agent/InstrumentationCallee

 

好了,咱们不管什么错误了,咱们就进行一次完整的配置,我就用jar程序测试,编写一个swing程序作为测试。

 

第一步:运行软件,进入界面,会弹出一个Quick Start对话框,在快速启动窗体中选择“An application server,locally or remotely,点击Next

jprofiler使用

第二步:进入向导,选择[Generic application],点击Next,(如果你想检测的是Tomcat或者其他服务器,远程服务器的话,就选择下面相应的服务器类型)

jprofiler使用

第三步:选择“On this computer(默认选项),因为我们是本地运行,所以就是选择本地,如果是远程的话,监控机跟服务器都要安装JProfiler。选择后点击Next

jprofiler使用

第四步:配置我们JVMJVM Vendor选择SunVersion我用的是1.6.X所以就选择1.6.0,点击Next

jprofiler使用

第五步:默认选择就行,点击Next

jprofiler使用


第六步:设置端口,默认就行,点击Next
jprofiler使用

第七步:这里要注意了,我们要复制下中间粗体字,如图红色地方所示,点击Next

jprofiler使用

第八步:选择,稍后启动,点击Finish
jprofiler使用

然后接下来就是配置我们的程序了,新建bat文件,或者直接执行java 然后添加运行参数

-agentpath:E:\JPROFI~1\bin\windows\jprofilerti.dll=port=8849

就是咱们刚才复制下来的

jprofiler使用

然后执行我们的bat文件,或者运行cmd再打开的cmd.exe中执行

java -agentpath:E:\JPROFI~1\bin\windows\jprofilerti.dll=port=8849 -jar ServerManager.jar

如图红色区域。执行完后会提示:

   Waiting for a connection from the JProfiler GUI…

jprofiler使用

然后,我们在JProfiler程序中点击Start Center

jprofiler使用

选择我们刚才创建的session,点击右边的jprofiler使用我们可以编辑配置信息

jprofiler使用

这里我们就不编辑了,直接点击Start
jprofiler使用

选择:Instrumentation

jprofiler使用

点击“OK”,
jprofiler使用

就会自动运行软件,显示监控数据了。

jprofiler使用

当然启动方式还有很多,这里就不一一列举了,不过有时候为了方便,注意要将软件的bin目录添加到CLASSPATH环境变量里,然后这是-server启动,这里设置-server的时候要注意注册表

   HKLM\software\JavaSoft\Java Runtime Environment 下的jre的目录中存在不存在server文件夹。

 

     转载请注明出处:http://yangcun.chongeronline.com & http://blog.sina.com.cn/xiaobai278