ホームページ  >  記事  >  Java  >  Java 9 における jcmd ツールの重要性は何ですか?

Java 9 における jcmd ツールの重要性は何ですか?

PHPz
PHPz転載
2023-09-15 18:21:031274ブラウズ

jcmd工具在Java 9中的重要性是什么?

"jcmd" は JVM Diagnostic ツールであり、指定された JVM をローカルでターゲットにするために使用されるコマンド ライン ツールです。マシン上の診断コマンド。このツールは、バージョン Java 7 以降の JDK インストールに含まれており、「%java_home%\bin\jcmd.exe」プログラム ファイルで表すことができます。環境変数「path」に「%java_home%\bin」ディレクトリを含めると、「jcmd -h」コマンドを実行してすべてのディレクトリの完全なリストを表示できます。オプションは次のとおりです

<strong>C:\Users\User>jcmd -h
Usage: jcmd
   or: jcmd -l
   or: jcmd -h

   command must be a valid jcmd command for the selected jvm.
   Use the command "help" to see which commands are available.
   If the pid is 0, commands will be sent to all Java processes.
   The main class argument will be used to match (either partially
   or fully) the class used to start Java.
   If no options are given, lists Java processes (same as -l).

   PerfCounter.print display the counters exposed by this process
   -f read and execute commands from the file
   -l list JVM processes on the local machine
   -h this help</strong>

Example

public class JCmdToolTest {
   public static void main(String args[]) {
      <strong>Runtime </strong>runtime = Runtime.<strong>getRuntime()</strong>;
      System.out.println("Free memory: " + runtime.<strong>freeMemory()</strong>);
      System.out.println("Total memory: " + runtime.<strong>totalMemory()</strong>);
      try {
         Thread.sleep(5000);
      } catch(InterruptedException e) {
      }
   }
}

Output

<strong>Free memory: 65454560
Total memory: 67108864</strong>

#「jcmd -l」を使用できます" コマンド ライン 実行中のすべての JVM マシンをローカルに出力し、出力内の PID またはクラス main を使用して JVM を識別します。

えええええ

以上がJava 9 における jcmd ツールの重要性は何ですか?の詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はtutorialspoint.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。