Arthas Java Diagnostic Tool: Installation, Common Commands, and Usage Guide
This article introduces Arthas, Alibaba's open‑source Java diagnostic tool, explains its installation via wget and java‑jar, and provides detailed usage of common commands such as stack, jad, sc, watch, trace, jobs, logger, dashboard, and redefine for real‑time JVM monitoring and debugging.
Arthas is an Alibaba‑open‑source Java diagnostic tool that enables dynamic tracing of Java code and real‑time JVM monitoring without stopping the application, supporting JDK 6+ on Linux, macOS, and Windows.
Installation
Download the boot jar and start it with wget https://alibaba.github.io/arthas/arthas-boot.jar followed by java -jar arthas-boot.jar. After starting, select the target application by its number.
Common Commands
1. stack – shows the call stack of a method, e.g.,
stack com.baomidou.mybatisplus.extension.service.IService getOne.
2. jad – decompiles a loaded class, e.g., jad cn.test.mobile.controller.order.OrderController or
jad cn.test.mobile.controller.order.OrderController getOrderInfo.
3. sc (Search‑Class) – searches loaded classes by pattern, e.g., sc *OrderController* or sc -d cn.test.mobile.controller.order.OrderController.
4. watch – monitors method parameters and return values, e.g.,
watch cn.test.mobile.controller.order.OrderController getOrderInfo "{params,returnObj}" -x 2.
5. trace – prints the internal call chain with timing, e.g.,
trace -j cn.test.mobile.controller.order.OrderController getOrderInfoand can filter by cost.
6. jobs – runs commands in background, e.g.,
trace -j cn.test.mobile.controller.order.OrderController getOrderInfo > test.out &, then list with jobs, manage with options job-timeout 2d and kill 76.
7. logger – view and update logger levels, e.g., logger --name ROOT --level debug.
8. dashboard – displays real‑time JVM metrics such as thread states, CPU usage, memory usage, and GC statistics.
9. redefine – hot‑updates already loaded classes without restarting; workflow includes decompiling with jad --source-only, editing the source, compiling with mc -c 18b4aac2 OrderController.java -d ./, and applying with redefine -c 18b4aac2 OrderController.class.
The article also covers troubleshooting when launching Arthas‑boot, such as selecting the correct Java process and changing telnet ports.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Architecture Digest
Focusing on Java backend development, covering application architecture from top-tier internet companies (high availability, high performance, high stability), big data, machine learning, Java architecture, and other popular fields.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
