Support Wikipedia Follow My Heart: How to run VisualVM in Ubuntu

2011年11月24日星期四

How to run VisualVM in Ubuntu

Today I spent one hour struggling with running VisualVM in Ubuntu.
I am new hand in Linux OS. So I hope my experience can help people in similar conditions.
First, of course, you need to install Java Development Kit (JDK) into your ubuntu since it is not defauly installed.
The command I used is:

java –version (# make sure the path is correct, and “JDK” reveals in the path) (# if your installation of JAVA failed, you cannot get correct response by this command)
Second, it is time to install VisualVM.
VisualVM is free and open source software. If you install Sun-JDK, it is already binded. If you installed open-JDK like me, you need to download and install it independently.

After installation, the main code and resources of VisualVM can be found in default installation path (in my PC, it is “usr/lib/visualVM”), and the short cut start file (“jvisualvm”) will be created in “usr/lib”.
Third, before you directly run VisualVM, you MUST edit the auto-generated script file “jvisualvm” to match the java environment.
I hate using VI in Linux because I cannot remember hotkeys. So I installed leafpad (a simple notepad software) to edit txt files.


sudo chmod +w /usr/lib/jvisualvm (# use this command to change script file from “Readonly” mode to “Read & Write Mode”) sudo leafpad /usr/lib/jvisualvm (# use this command to invoke leafpad, to edit the content of script file -- jvisualvm)

The default content of script file MUST be changed, unless you cannot launch VisualVM successfully.
There is a section of code (as follows) in the file. (maybe starts from line 12). It means that the system checks all given paths (from [path1] to [path n]), if any path includes file “javac” in sub-folder “[path]/bin”, then VisualVM will use this path as “jdkhome”.
So here lies the problem.
WHEN YOU INSTALL VISUALVM, the content of this script file will not be updated according to your own JAVA ENVIRONMENT.
so I changed the this section of code as follows to solve the problem (by inserting my JDK path into condition part):
DO NOT FORGET TO SAVE THE FILE!
DO NOT FORGET TO REOPEN THE FILE TO CHECK YOUR CHANGE!
Now, you can successfully invoke VisualVM.
Enjoy monitoring!

没有评论:

发表评论