In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what are the commonly used commands in JDK". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn what are the commands commonly used in JDK.
JDK common commands
First I'll show you a general picture, and then we'll order you to use it one by one and feel it.
JPS
Description: first of all, from the figure above, we can see that all the JVM of the current system can be found when using the jps or jps | grep-v Jps command. The second command above is to filter its own Jps program. As you can see, after entering this command, all the Java programs on the current system are displayed, and the process number pid (that is, the previous number) is output.
Let's simply take a look at the instructions by commanding man jps, as follows:
You can see that the jps command has five parameters, each of which has the following meaning
-Q: does not output class name information and parameters, only the process number
-m: displays the parameters entered into the main method
-l: show the full path of main class
-v: displays the parameters of the input JVM
-V: no path output, only process number and jar output
Let's enter it one by one, as shown in the following figure.
Jinfo
Through the previous step, we can get the process number of the corresponding JVM, which provides convenience for our subsequent operations, which will use the process number for subsequent operations.
Let's first use the command. Before using it, let's get the process number. My server is running a process number of 2528, and then type jinof 2528.
From the figure above, we can see the current version of JVM and other details, as well as a series of information such as the server and environment variables. Similarly, let's use the man jinfo command to take a look at the manual.
This command is mainly for users to view information about the current virtual machine, which we will not introduce too much.
Jstat
The jstat command is mainly used to monitor the status of the virtual machine, and you can view the GC of the virtual machine. The following command jstat-gcutil 2528 1000 10 indicates that the GC of process 2528 is output every 1000 milliseconds, and a total of 10 times.
The manual of jstat is relatively long, if you are interested, you can check it by yourself. here, only the above part is posted for you to see.
If the jstat-gcutil 2528 1000 10 executed above is modified to this jstat-gcutil-h4 2528 1000 10, the final effect will be the following figure. We can see that a header is added every three lines, and you can try more commands yourself.
Jmap
The jmap command is used to generate the dump file, and the jmap-dump:live,format=b,file=dump.bin 2528 creates the dump file as follows.
Through the jmap command, we can generate a memory snapshot file, which can be used to analyze the memory information when the program is abnormal, and can be better used with the jhat command.
Jhat
It is mentioned above that we generated a memory snapshot file when using jmap, so how do we view this memory file? Here you need to combine the jhat command. We can use jhat dump.bin to start a service and then open the default port 7000 through the browser to view the information.
Access to port 7000 is as follows:
Jstack
Jstack is used to generate thread snapshots of the current time of java virtual machines. Thread snapshots are a collection of method stacks that each thread is executing in the current java virtual machine. The main purpose of generating thread snapshots is to locate the causes of thread pauses for a long time, such as deadlocks between threads, deadloops, long waits caused by requests for external resources, and so on. When a thread pauses, look at the call stack of each thread through jstack, and you can know what the unresponsive thread is doing in the background or waiting for what resources.
Use the command jstack 2528 to view the thread stack as follows:
Through this command, we can see the execution of the threads corresponding to the process, and we can analyze which threads are allowed and which are waiting.
At this point, I believe you have a deeper understanding of "what are the commands commonly used in JDK?" you might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.