Use btrace in a jre-only Environment

Source: Internet
Author: User

Btrace is a Java-based tool that can dynamically track bytecode. It can monitor the execution status of Java programs at runtime without modifying the current program, for example, you can monitor the memory status and call methods. However, it can only run on JDK 6 + and later versions. for some reasons, for example, in JDK 5, jtwti (Java Virtual Machine toolkit interface: Java Virtual Machine Tool interface, refer to this article: http://www.ibm.com/developerworks/cn/java/j-lo-jvmti/), only supports native-based
Library, rather than a jar-based proxy.

It is very simple to use, the simplest is to write the Java source code, directly put it in its bin directory to execute it, it has a detailed userguide: Compile.

However, in some cases, we do not have JDK In the runtime environment, but only JRE. We need to make some modifications to btrace for normal use.

1. Copy tools. jar from JDK to a suitable directory (such as./tmp );
2. set libattach from JDK. so is also copied to the above directory (ex. /tmp)-This file should be selected based on the number of operating system digits of the current running system, such as 32-bit or 64-bit, we need to select a file from the appropriate JDK;
3. modify the btrace script. The script is in the bin directory. Modify different btrace files based on different systems-change tools_jar = "$ {java_home}/lib/tools. jar "changed to the tool copied above. jar;
4. modify the btrace script. The script is under the bin directory. Modify different btrace files based on different systems-Modify the line executed by Java (I. e. is the row starting with $ java_home}/bin/Java.) Add the parameter-djava. library. path =/tmp, the/tmp directory is where we store libattach. so file location;
5. Execute the command according to the original execution method.

The above is translated to: https://kenai.com/projects/btrace/forums/tips-tricks/topics/13119-Using-BTrace-with-JRE-as-a-target-VM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.