├── .gitignore ├── 00_Preface └── README.md ├── 01_How_Classes_are_Found └── README.md ├── 02_Setting_the_Class_Path └── README.md ├── 03_JDK_JRE_File_Structure └── README.md ├── 04_Command_Reference └── README.md ├── 05_Create_and_Build ├── 05_08_javap.md └── README.md ├── 06_Security └── README.md ├── 07_Internationalization ├── README.md └── native2ascii.md ├── 08_RMI └── README.md ├── 09_Java_IDL_RMI-IIOP └── README.md ├── 10_Deploy └── README.md ├── 11_Java_Web_Start └── README.md ├── 12_Monitor_Java_App ├── 1201.md ├── 1202.md └── README.md ├── 13_Monitor_JVM ├── 1301_jps.md ├── 1302_jstat.md ├── 1303_jstatd.md ├── 1304_jmc.md └── README.md ├── 14_Web_Services └── README.md ├── 15_Troubleshooting ├── README.md ├── jcmd.md ├── jhat.md ├── jinfo.md ├── jmap.md ├── jsadebugd.md └── jstack.md ├── 16_Scripting └── README.md ├── Copyright_Information.md ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | 3 | # Mobile Tools for Java (J2ME) 4 | .mtj.tmp/ 5 | 6 | # Package Files # 7 | *.jar 8 | *.war 9 | *.ear 10 | 11 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 12 | hs_err_pid* 13 | -------------------------------------------------------------------------------- /00_Preface/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/00_Preface/README.md -------------------------------------------------------------------------------- /01_How_Classes_are_Found/README.md: -------------------------------------------------------------------------------- 1 | # 1 How Classes are Found 2 | 3 | # 1. Java如何查找Class 4 | 5 | 6 | The java command is called the Java launcher because it launches Java applications. When the Java launcher is called, it gathers input from the user and the user's environment (such as the class path and the boot class path), interfaces with the Virtual Machine (VM), and gets it started via some bootstrapping. The Java Virtual Machine (JVM) does the rest of the work. 7 | 8 | `java` 命令被称为 Java launcher, 因为它启动java应用. 当调用 Java launcher 启动程序时, 它收集用户输入以及用户环境(如类路径(class path)和引导类路径(boot class path) ), 虚拟机(VM)接口, 并通过一些引导来开始。剩下的工作由Java虚拟机(JVM)负责。 9 | 10 | 11 | This chapter covers the following topics: 12 | 13 | 本章包括以下主题: 14 | 15 | 16 | How the Java Runtime Finds Classes 17 | 18 | Java运行时如何发现类 19 | 20 | 21 | How the javac and javadoc Commands Find Classes 22 | 23 | javac 和 javadoc 命令如何发现类 24 | 25 | 26 | Class Loading and Security Policies 27 | 28 | 类加载和安全策略 29 | 30 | 31 | ## How the Java Runtime Finds Classes 32 | 33 | ## Java运行时如何发现类 34 | 35 | 36 | The JVM searches for and loads classes in this order: 37 | 38 | JVM以下面的顺序来查找和加载类: 39 | 40 | 41 | 1. Bootstrap classes, which are classes that comprise the Java platform, including the classes in rt.jar and several other important JAR files. 42 | 43 | 1. 引导类(Bootstrap classes), 由Java平台组成, 包括 `rt.jar` 和其他几个重要的JAR文件中的类。 44 | 45 | 46 | 2. Extension classes, which use the Java Extension mechanism. These classes are bundled as JAR files and located in the extensions directory. 47 | 48 | 2. 扩展类(Extension classes), 使用Java扩展机制(Extension mechanism)。这些类被打包为JAR文件, 放在扩展目录中。 49 | 50 | 51 | 3. User classes are classes that are defined by developers and third parties and that do not take advantage of the extension mechanism. You identify the location of these classes with the -classpath option on the command line (preferred) or with the CLASSPATH environment variable. See [Setting the Class Path](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/classpath.html#CBHHCGFB). 52 | 53 | 3. 用户类(User classes), 是由开发人员和第三方定义的类, 不利用扩展机制. 你可以通过命令行设置 `-classpath` 选项来确定这些类的位置(优先). 还可以设置 **CLASSPATH** 环境变量。可以参考 [Setting the Class Path](../02_Setting_the_Class_Path/)。 54 | 55 | 56 | In effect, the three search paths together form a simple class path. This is similar to the flat class path previously used, but the current model has the following improvements: 57 | 58 | 实际上,这三个搜索路径组成一个简单的类路径。这类似于之前使用的平坦类路径,但目前的模型有以下改进: 59 | 60 | 61 | * It is relatively difficult to accidentally hide or omit the bootstrap classes. 62 | 63 | * 相对很难隐藏或省略引导类。 64 | 65 | 66 | * In general, you only have to specify the location of user classes. Bootstrap classes and extension classes are found automatically. 67 | 68 | * 在一般情况下,您只需要指定用户类的位置。引导类和扩展类会自动发现。 69 | 70 | 71 | * The tools classes are now in a separate archive (tools.jar) and can only be used if included in the user class path described in How the Java Runtime Finds Bootstrap Classes. 72 | 73 | * 工具类现在在一个单独的包中(`tools.jar`), 只有包含在用户类路径中才能使用, 参考下面的 **Java运行时如何发现引导类**。 74 | 75 | 76 | ## How the Java Runtime Finds Bootstrap Classes 77 | 78 | 79 | ## Java运行时如何发现引导类 80 | 81 | 82 | Bootstrap classes are the classes that implement Java SE. Bootstrap classes are in the rt.jar file and several other JAR files in the jre/lib directory. These archives are specified by the value of the bootstrap class path that is stored in the sun.boot.class.path system property. This system property is for reference only and should not be directly modified.It is unlikely that you will need to redefine the bootstrap class path. The nonstandard option, -Xbootclasspath, allows you to do so in those rare circumstances in which it is necessary to use a different set of core classes. 83 | 84 | 引导类就是Java SE的实现类。位于 rt.jar 和 jre/lib 目录下的其他几个 JAR 文件中. 这些文件由 `sun.boot.class.path` 属性所指定,叫做 **bootstrap class path**。 这个系统属性只能引用, 不应直接修改。一般来说您不需要重新指定引导类路径. 有一个非标准选项, `-Xbootclasspath`、允许你在极端情况下指定使用其他地方的核心类。 85 | 86 | 87 | Note that the classes that implement the JDK tools are in a separate archive from the bootstrap classes. The tools archive is the JDK /lib/tools.jar file. The development tools add this archive to the user class path when invoking the launcher. However, this augmented user class path is only used to execute the tool. The tools that process source code, the javac command, and the javadoc command, use the original class path, not the augmented version. For more information, see How the javac and javadoc Commands Find Classes. 88 | 89 | 注意, 实现了JDK工具的类和引导类位于不同的jar文件之中。工具类位于 `/lib/tools.jar` 文件. 开发工具在启动时将这个jar添加到用户类路径。然而, 这种增强的用户类路径只用于执行工具. 而处理源代码的工具, 例如 `javac` 命令,和 `javadoc` 命令,使用的是原始的类路径, 而不是增强版本. 有关更多信息,请参考下面的 [javac和javadoc命令如何找到类]()。 90 | 91 | 92 | ## How the Java Runtime Finds Extension Classes 93 | 94 | ## Java运行时如何发现扩展类 95 | 96 | 97 | Extension classes are classes that extend the Java platform. Every .jar file in the extension directory, jre/lib/ext, is assumed to be an extension and is loaded with the Java Extension Framework. Loose class files in the extension directory are not found. They must be contained in a JAR file or Zip file. There is no option provided for changing the location of the extension directory. 98 | 99 | 扩展类(Extension classes)是扩展Java平台的类。每一个位于 `jre/lib/ext` 目录下的 jar 文件, 都被当做扩展类, 由 Java Extension Framework 负责加载. 没有打成 jar 包的 class 文件不会被加载。他们必须包含在一个JAR文件或Zip文件中。没有任何选项来改变扩展目录的位置。 100 | 101 | 102 | If the jre/lib/ext directory contains multiple JAR files, and those files contain classes with the same name such as in the following example, the class that actually gets loaded is undefined. 103 | 104 | 如果 `jre/lib/ext` 目录下包含多个JAR文件, 而这些文件中又包含了具有相同名称的类, 例如下面的例子, 则实际加载到哪一个是不确定的。 105 | 106 | 107 | > smart-extension1_0.jar contains class smart.extension.Smart 108 | > 109 | > smart-extension1_1.jar contains class smart.extension.Smart 110 | 111 | 112 | ## How the Java Runtime Finds User Classes 113 | 114 | ## Java运行时如何发现用户类 115 | 116 | 117 | To find user classes, the launcher refers to the user class path, which is a list of directories, JAR files, and Zip files that contain class files. 118 | 119 | 加载器根据用户类路径来查找用户类, 这是一个包含类文件的列表, 其中可以包含 目录, JAR文件和Zip文件。 120 | 121 | 122 | A class file has a subpath name that reflects the fully-qualified name of the class. For example, if the class com.mypackage.MyClass is stored under myclasses, then myclasses must be in the user class path, and the full path to the class file must be /myclasses/com/mypackage/MyClass.class on Oracle Solaris or in \myclasses\com\mypackage\MyClass.class on Windows. 123 | 124 | 包含子路径的类文件名字反映了类的完全限定名称。例如,如果类 `com.mypackage.MyClass` 存储在 myclasses 目录下, 那么必须将 `myclasses` 设置到用户类路径之中, 而且类文件的完整路径, 在Linux或者 Unix下必须是 `/myclasses/com/mypackage/MyClass.class`。在Windows上 必须是`\myclasses\com\mypackage\MyClass.class`。 125 | 126 | 127 | If the class is stored in an archive named myclasses.jar, then myclasses.jar must be in the user class path, and the class file must be stored in the archive as com/mypackage/MyClass.class on Windows or in com\mypackage\MyClass.class on Oracle Solaris. 128 | 129 | 如果类被打包在 myclasses.jar 文件中, 那么 ` myclasses.jar` 必须加入到用户类路径中, 而 class 文件也必须存放在 jar 文件的 `com/mypackage/MyClass.class` 位置。 130 | 131 | 132 | The user class path is specified as a string, with a colon (:) to separate the class path entries on Oracle Solaris, and a semicolon (;) to separate the entries on Windows systems. The Java launcher puts the user class path string in the java.class.path system property. The possible sources of this value are: 133 | 134 | 用户类路径通过一个字符串来指定, 在Oracle Solaris或者Linux上通过英文冒号(:)来分隔, 在Windows系统上通过英文分号(;)来分隔. Java启动程序将用户类路径字符串设置到给`java.class.path` 这个系统属性。这个值可能的来源有: 135 | 136 | 137 | * The default value, *.*, which means that user class files are all the class files in or under the current directory. 138 | 139 | * 默认值 `*.*` ,意思是当前目录下的所有 class 文件都是用户类。 140 | 141 | * The value of the CLASSPATH environment variable that overrides the default value. 142 | 143 | * 环境变量 **CLASSPATH** 如果有值,则会覆盖默认值。 144 | 145 | 146 | * The value of the -cp or -classpath command-line option that overrides both the default value and the CLASSPATH value. 147 | 148 | * 命令行选项 `-cp` 或者 `-classpath` 的值,会覆盖 默认值以及 CLASSPATH 的值。 149 | 150 | 151 | * The JAR archive specified by the -jar option overrides all other values if it contains a Class-Path entry in its manifest. If this option is used, all user classes must come from the specified archive. 152 | 153 | 154 | * 通过 `-jar` 选项指定的 JAR 文件, 如果其 manifest 中指定了`Class-Path` 条目, 则会覆盖所有其他的值. 如果是这样, 那么所有的用户类都必须来自指定的jar文件。 155 | 156 | 157 | ## How the Java Runtime Finds JAR-class-path Classes 158 | 159 | ## Java运行时如何发现 JAR-class-path 的类 160 | 161 | 162 | A JAR file usually contains a manifest, which is a file that lists the contents of the JAR file. The manifest can define a JAR class path, which further extends the class path, but only while loading classes from that JAR file. Classes accessed by a JAR class path are found in the following order: 163 | 164 | 通常每个JAR文件包含一个 manifest 清单, 清单文件中列出了JAR文件的内容. manifest 可以定义JAR class path, 从而进一步扩展 class path, 但这只适用于从该 JAR 包加载类的时候, 由JAR class path 引用的类通过以下顺序进行查找: 165 | 166 | 167 | 1. In general, classes referenced by a JAR class path entry are found as though they are part of the JAR file. The JAR files that appear in the JAR-class-path are searched after any earlier class path entries and before any entries that appear later in the class path. 168 | 169 | 1. 一般来说,JAR class path 条目引用的类路径都是JAR文件中的一部分.出现在 JAR-class-path 中的JAR文件,搜索顺序也是由其出现的顺序决定。 170 | 171 | 172 | 2. If the JAR class path points to a JAR file that was already searched, for example, an extension or a JAR file that was listed earlier in the class path, then that JAR file is not searched again. This optimization improves efficiency and prevents circular searches. This type of JAR file is searched at the point that it appears, which is earlier in the class path. 173 | 174 | 2. 如果 JAR class path 指向一个已经查找过的JAR文件,例如,扩展类或者前面的 class path 中列出的类路径, 则 JAR 文件不会被再次搜索. 这种优化提高了效率,并且阻止了循环搜索。这种类型的JAR文件在出现时进行搜索, 早于 class path。 175 | 176 | 177 | 3. If a JAR file is installed as an extension, then any JAR class path it defines is ignored. All of the classes required by an extension are presumed to be part of the JDK or to have been installed as extension. 178 | 179 | 3. 如果JAR文件被安装为扩展, 那么指定的所有JAR文件都会被忽略. 扩展类所需的任何类, 都被假定为是JDK的一部分,或者是已经安装为一个扩展。 180 | 181 | 182 | ## How the javac and javadoc Commands Find Classes 183 | 184 | ## javac和javadoc命令如何找到类 185 | 186 | The javac and javadoc commands use class files in the following two ways: 187 | 188 | javac和javadoc命令通过以下两种方式使用类文件: 189 | 190 | * To run, the javac and javadoc commands must load various class files. 191 | 192 | * 用来运行,javac和javadoc命令必须加载各种不同的类文件。 193 | 194 | 195 | * To process the source code they operate on, the javac and javadoc commands must obtain information on object types used in the source code. 196 | 197 | * 要处理源代码, javac和javadoc命令必须获得源代码中使用的对象的类型信息。 198 | 199 | 200 | The class files used to resolve source code references are mostly the same class files used to run the javac and javadoc commands. But there are some important exceptions, as follows: 201 | 202 | 用于解决源代码引用的类文件大多和用于运行javac和javadoc命令的是同样的 class 文件。但也有一些重要的例外: 203 | 204 | 205 | * Both the javac and javadoc commands often resolve references to classes and interfaces that have nothing to do with the implementation of the javac or javadoc commands. Information on referenced user classes and interfaces might be present in the form of class files, source code files, or both. 206 | 207 | * javac和javadoc命令通常引用的类和接口都是和 javac或javadoc命令的实现无关的类. 信息通常存在于引用的用户类/接口的 class 文件, 源代码文件,或两者兼而有之。 208 | 209 | 210 | * The tools classes in the tools.jar file are only used to run the javac and javadoc commands. The tools classes are not used to resolve source code references unless the tools.jar file is in the user class path. 211 | 212 | * tools.jar 中的工具类只用于运行javac和javadoc命令。tools classes 一般不用于解决源码中的引用, 除非 tools.jar 文件出现在用户类路径之。 213 | 214 | 215 | * A programmer might want to resolve boot class or extension class references with an alternative Java platform implementation. Both the javac and javadoc commands support this with their -bootclasspath and -extdirs options. Use of these options does not modify the set of class files used to run the javac or javadoc commands themselves. 216 | 217 | * 程序员可能会使用另一种Java平台实现来解决引导类或扩展类引用. javac 和 javadoc命令支持 `-bootclasspath` 和 `-extdirs` 选项. 使用这些选项不会修改运行 javac或javadoc命令自身的 class 文件集合。 218 | 219 | 220 | If a referenced class is defined in both a class file and a source file, the javadoc command always uses the source file. The javadoc command never compiles source files. In the same situation the javac command uses class files, but automatically recompiles any class files it determines to be out of date. The rules for automatic recompilation are documented in javac. 221 | 222 | 如果某个被引用的类中出现在 class 文件之中, 也出现在源文件之中, 则 javadoc 命令总是使用源文件。而 javadoc命令绝不编译源文件(因为他只是一个文档工具而已). 同样的情况下, javac命令使用 class 文件, 但自动重新编译那些他认为陈旧的 class 文件。自动重新编译的规则请参考 [javac 文档](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html)。 223 | 224 | 225 | By default, the javac and javadoc commands search the user class path for both class files and source code files. If the -sourcepath option is specified, the javac and javadoc commands search for source files only on the specified source file path, while still searching the user class path for class files. 226 | 227 | 默认情况下, javac和javadoc命令查找用户类路径下的 class 文件和源代码文件. 如果指定了 `-sourcepath` 选项, javac和javadoc命令只在指定的源文件路径下搜索源文件, 同时搜索的用户类路径下的 class 文件。 228 | 229 | 230 | ## Class Loading and Security Policies 231 | 232 | ## 类加载和安全策略 233 | 234 | To be used, a class or interface must be loaded by a class loader. Use of a particular class loader determines a security policy associated with the class loader. 235 | 236 | 237 | 要使用类加载和安全策略, 必须通过 class loader 来加载一个类或接口。使用一个特定的类加载器就确定了与类加载器相关联的一个安全策略。 238 | 239 | 240 | A program can load a class or interface by calling the loadClass method of a class loader object. But usually a program loads a class or interface by referring to it. This invokes an internal class loader, which can apply a security policy to extension and user classes. If the security policy has not been enabled, all classes are trusted. Even if the security policy is enabled, it does not apply to bootstrap classes, which are always trusted. 241 | 242 | 程序可以通过类加载器对象的 `loadClass` 方法来加载一个类或接口。但通常通过指向一个类来加载一个类或接口. 这会调用内部的类加载器, 其可以将安全策略应用于扩展类和用户类。如果安全策略尚未启用, 所有类都是可信的. 即使启用了安全策略,它也不适用于引导类,因为总是信任 bootstrap classes。 243 | 244 | 245 | When enabled, security policy is configured by system and user policy files. The Java platform SDK includes a system policy file that grants trusted status to extension classes and places basic restrictions on user classes. 246 | 247 | 启用时,安全策略通过系统和用户策略文件配置. Java平台的SDK包含一个系统策略文件, 授予对扩展类的信任状态,以及对用户类给予基本限制。 248 | 249 | 250 | To enable or configure the security policy, refer to Security Features. 251 | 252 | 启用或配置安全策略, 请参阅 [安全特性]()。 253 | 254 | 255 | Note: Some security programming techniques that worked with earlier releases of Java SE are incompatible with the class loading model of the current release. 256 | 257 | > **注意**: 早期Java SE版本的一些安全编程技术和当前版本的类加载模型是不兼容的。 258 | 259 | 260 | 原文链接: [http://docs.oracle.com/javase/8/docs/technotes/tools/windows/findingclasses.html](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/findingclasses.html) 261 | 262 | 263 | 264 | 265 | 266 | -------------------------------------------------------------------------------- /02_Setting_the_Class_Path/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/02_Setting_the_Class_Path/README.md -------------------------------------------------------------------------------- /03_JDK_JRE_File_Structure/README.md: -------------------------------------------------------------------------------- 1 | # 3. JDK and JRE File Structure 2 | 3 | # 3. JDK 和 JRE 的目录结构 4 | 5 | 6 | This chapter introduces the JDK directories and the files they contain. The file structure of the JRE is identical to the structure of the jre directory in the JDK. 7 | 8 | 本章介绍JDK目录和其中包含的文件。JRE的文件结构与JDK 内部的 jre 目录结构是一致的。 9 | 10 | 11 | This chapter covers the following topics: 12 | 13 | 本章包括以下主题: 14 | 15 | 16 | - Demos and Samples 17 | 18 | - 演示和示例 19 | 20 | 21 | 22 | - Development Files and Directories 23 | 24 | - 开发包的文件和目录 25 | 26 | 27 | 28 | - Additional Files and Directories 29 | 30 | - 附加文件和目录 31 | 32 | 33 | 34 | ## Demos and Samples 35 | 36 | ## 演示和示例 37 | 38 | 39 | Demos and samples that show you how to program for the Java platform are available as a separate download at the Java SE Downloads page at 40 | http://www.oracle.com/technetwork/java/javase/downloads/index.html 41 | 42 | 演示和示例,告诉你如何使用Java平台编程, 可以在 Java SE的下载页面单独下载: 43 | [http://www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 44 | 45 | 46 | These are available as separate .tar.z compressed packages and .tar.gz compressed binaries. Similar to other 64-bit bundles on Oracle Solaris, the 64-bit demos and samples bundles on Oracle Solaris require that the 32-bit demos and samples bundles to also be installed. 47 | 48 | 都可作为单独的 `.tar.z` 压缩包或者 `.tar.gz` 压缩包。和其他的64位程序包一样, 在Oracle Solaris上, 64位的 emos and samples 需要安装32位的 demos and samples。 49 | 50 | 51 | ## Development Files and Directories 52 | 53 | ## 开发包的文件和目录 54 | 55 | 56 | This section describes the most important files and directories required to develop applications for the Java platform. Some of the directories that are not required include Java source code and C header files. See Additional Files and Directories. 57 | 58 | 本节描述Java平台开发所需的最重要的文件和目录. 有些目录不是必须的, 例如 Java源代码和C头文件。参加下方的 [附加文件和目录]()。 59 | 60 | 61 | jdk1.8.0 62 | bin 63 | java* 64 | javac* 65 | javap* 66 | javah* 67 | javadoc* 68 | lib 69 | tools.jar 70 | dt.jar 71 | jre 72 | bin 73 | java* 74 | lib 75 | applet 76 | ext 77 | jfxrt.jar 78 | localdata.jar 79 | fonts 80 | security 81 | sparc 82 | server 83 | client 84 | rt.jar 85 | charsets.jar 86 | 87 | 88 | 89 | 90 | Assuming the JDK software is installed at /jdk1.8.0, here are some of the most important directories: 91 | 92 | 假设 JDK 安装目录为 `/jdk1.8.0`, 下面是一些最重要的目录: 93 | 94 | 95 | > ### /jdk1.8.0 96 | 97 | 98 | 99 | Root directory of the JDK software installation. Contains copyright, license, and README files. Also contains src.zip, the archive of source code for the Java platform. 100 | 101 | JDK的根目录。包含 copyright, license 和 README文件。还包含Java平台的源代码压缩包 `src.zip`。 102 | 103 | 104 | > ### /jdk1.8.0/bin 105 | 106 | 107 | 108 | Executables for all the development tools contained in the JDK. The PATH environment variable should contain an entry for this directory. 109 | 110 | 包含了JDK中所有可执行的开发工具。PATH环境变量应该包含此目录。 111 | 112 | 113 | > ### /jdk1.8.0/lib 114 | 115 | 116 | 117 | Files used by the development tools. Includes tools.jar, which contains non-core classes for support of the tools and utilities in the JDK. Also includes dt.jar, the DesignTime archive of BeanInfo files that tell interactive development environments (IDEs) how to display the Java components and how to let the developer customize them for an application. 118 | 119 | 开发者工具(development tools)所使用的文件。包括 `tools.jar`, 其中都是非核心类, 用于支持JDK工具和实用程序。还包括`dt.jar`, 支持 DesignTime 的 BeanInfo文件信息, 告诉交互式开发环境(IDE)如何显示Java组件, 以及如何让开发人员编写应用程序。 120 | 121 | 122 | > ### /jdk1.8.0/jre 123 | 124 | 125 | 126 | 127 | Root directory of the Java Runtime Environment (JRE) used by the JDK development tools. The runtime environment is an implementation of the Java platform. This is the directory referred to by the java.home system property. 128 | 129 | JDK development tools所使用的Java运行时环境(JRE)的根目录。运行时环境是Java平台的一个实现, 是系统属性 `java.home` 所指向的目录。 130 | 131 | 132 | > ### /jdk1.8.0/jre/bin 133 | 134 | 135 | 136 | Executable files for tools and libraries used by the Java platform. The executable files are identical to files in /jdk1.8.0/bin. The java launcher tool serves as an application launcher (and replaced the earlier jre command that shipped with 1.1 releases of the JDK). This directory does not need to be in the PATH environment variable. 137 | 138 | Java平台所使用的工具和库的可执行文件。和 `/jdk1.8.0/bin` 下面的是相同的文件。java启动程序工具作为一个应用程序启动器(取代了JDK 1.1版本早期附带的 jre 命令). 此目录不需要在PATH环境变量中指定。 139 | 140 | 141 | > ### /jdk1.8.0/jre/lib 142 | 143 | 144 | 145 | 146 | Code libraries, property settings, and resource files used by the JRE. For example rt.jar contains the bootstrap classes, which are the run time classes that comprise the Java platform core API, and charsets.jar contains the character-conversion classes. Aside from the ext subdirectory, there are several additional resource subdirectories not described here. 147 | 148 | JRE使用的代码库、属性设置和资源文件。例如 `rt.jar`, 包含引导类, 是Java平台的运行时类以及核心API。还有 `charsets.jar` 包含字符转换类。 除了 ext 子目录, 其他的几个附加资源子目录这里不再展开描述。 149 | 150 | 151 | > ### /jdk1.8.0/jre/lib/ext 152 | 153 | 154 | 155 | 156 | Default installation directory for extensions to the Java platform. This is where the JavaHelp JAR file goes when it is installed, for example. This directory includes the jfxrt.jar file, which contains the JavaFX runtime libraries and the localedata.jar file, which contains the locale data for the java.text and java.util packages. See The Extension Mechanism at 157 | http://docs.oracle.com/javase/8/docs/technotes/guides/extensions/index.html 158 | 159 | Java平台默认的扩展安装目录。这就是 JavaHelp JAR文件安装的位置, 例如。这个目录包括 `jfxrt.jar` 文件, 其中包含了 JavaFX 的运行时库。例如 `localedata.jar` 文件,其中包含了 java.text 和 java.util 包使用的 locale 数据。Java的扩展机制请参考: 160 | [http://docs.oracle.com/javase/8/docs/technotes/guides/extensions/index.html](http://docs.oracle.com/javase/8/docs/technotes/guides/extensions/index.html) 161 | 162 | 163 | > ### /jdk1.8.0/jre/lib/security 164 | 165 | 166 | 167 | 168 | Contains files used for security management. These include the security policy java.policy and security properties java.security files. 169 | 170 | 包含用于安全管理的文件。包括 `java.policy` 安全策略,以及 `java.security` 安全属性文件。 171 | 172 | 173 | 174 | 175 | > ### /jdk1.8.0/jre/lib/sparc 176 | 177 | 178 | 179 | Contains the .so (shared object) files used by the Oracle Solaris release of the Java platform. 180 | 181 | 包含了 Java平台Oracle Solaris版本的 `.so` 文件。(.so 是 shared object 的缩写,类似于windows平台的 .dll 文件)。 182 | 183 | 184 | > ### /jdk1.8.0/jre/lib/sparc/client 185 | 186 | 187 | 188 | Contains the .so file used by the Java HotSpot VM client, which is implemented with Java HotSpot VM technology. This is the default Java Virtual Machine (JVM). 189 | 190 | 包含了 Java HotSpot VM client 客户端所使用的`.so`文件, 使用Java HotSpot VM技术实现。这是sparc下默认的Java虚拟机(JVM)。 191 | 192 | 193 | > ### /jdk1.8.0/jre/lib/sparc/server 194 | 195 | 196 | 197 | Contains the .so file used by the Java HotSpot VM server. 198 | 199 | 包含了 sparc 下 Java HotSpot VM server 使用的 `.so` 文件。 200 | 201 | 202 | > ### /jdk1.8.0/jre/lib/applet 203 | 204 | 205 | 206 | 207 | JAR files that contain support classes for applets can be placed in the lib/applet/ directory. This reduces startup time for large applets by allowing applet classes to be preloaded from the local file system by the applet class loader and provides the same protections as though they had been downloaded over the Internet. 208 | 209 | 支持 applet 的JAR文件可以放在 `lib/applet/` 目录中. 这降低了大型applet的启动时间,通过允许从本地文件系统预加载applet类,就像他们是从网络上下载的一样,提供了相同的安全保护。 210 | 211 | > 说明: Java即将删除Applet.当年一项惊爆眼球的酷炫技术,没能发展起来。 参考: [Oracle即将删除 Applet 插件](http://blog.csdn.net/renfufei/article/details/50609612) 212 | 213 | > ### /jdk1.8.0/jre/lib/fonts 214 | 215 | 216 | Font files used by the platform. 217 | 218 | 平台使用的字体文件。 219 | 220 | 221 | ## Additional Files and Directories 222 | 223 | ## 附加文件和目录 224 | 225 | 226 | This section describes the directory structure for Java source code, C header files, and other additional directories and files. 227 | 228 | 本节描述 Java source code,和 C header files 的目录结构, 以及其他附加的目录和文件。 229 | 230 | 231 | jdk1.8.0 232 | db 233 | include 234 | man 235 | src.zip 236 | 237 | 238 | 239 | 240 | > ### /jdk1.8.0/src.zip 241 | 242 | 243 | Archive that contains the source code for the Java platform. 244 | 245 | 包含Java平台源代码的归档文件(Archive,一般就是压缩包)。 246 | 247 | 248 | > ### /jdk1.8.0/db 249 | 250 | 251 | Contains Java DB. See Java DB Technical Documentation at 252 | http://docs.oracle.com/javadb/ 253 | 254 | 包含 Java DB, 详情请参考 Java DB 技术文档: [http://docs.oracle.com/javadb/](http://docs.oracle.com/javadb/) 255 | 256 | 257 | > ### /jdk1.8.0/include 258 | 259 | 260 | C-language header files that support native-code programming with the Java Native Interface and the Java Virtual Machine (JVM) Debugger Interface. See Java Native Interface at 261 | http://docs.oracle.com/javase/8/docs/technotes/guides/jni/index.html 262 | 263 | C语言的头文件, 用于支持JNI(Java Native Interface)编程与Java虚拟机(JVM)调试器接口编程。请参考 Java Native Interface 文档: 264 | [http://docs.oracle.com/javase/8/docs/technotes/guides/jni/index.html](http://docs.oracle.com/javase/8/docs/technotes/guides/jni/index.html) 265 | 266 | 267 | 268 | See also Java Platform Debugger Architecture (JPDA) at 269 | http://docs.oracle.com/javase/8/docs/technotes/guides/jpda/index.html 270 | 271 | 另请参见 Java平台调试器体系结构文档(JPDA, Java Platform Debugger Architecture): 272 | [http://docs.oracle.com/javase/8/docs/technotes/guides/jpda/index.html](http://docs.oracle.com/javase/8/docs/technotes/guides/jpda/index.html) 273 | 274 | 275 | > ### /jdk1.8.0/man 276 | 277 | 278 | 279 | Contains man pages for the JDK tools. 280 | 281 | 包含JDK tools 的用户手册(man 是 manual 的缩写)。 282 | 283 | 284 | 原文链接: [http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jdkfiles.html](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jdkfiles.html) 285 | 286 | 287 | 288 | 289 | 290 | -------------------------------------------------------------------------------- /04_Command_Reference/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/04_Command_Reference/README.md -------------------------------------------------------------------------------- /05_Create_and_Build/05_08_javap.md: -------------------------------------------------------------------------------- 1 | 2 | # javap 3 | 4 | Disassembles one or more class files. 5 | 6 | 展开(Disassembles)一到多个 `class` 文件 7 | 8 | ## javap概述(Synopsis) 9 | 10 | > **javap** _options_ _classfile_ ... 11 | 12 | - _options_ 13 | 14 | The command-line options. See Options. 15 | 16 | 命令行参数, 请参考下方的选项(Options)部分。 17 | 18 | - _classfile_ 19 | 20 | One or more classes separated by spaces to be processed for annotations such as `DocFooter.class`. You can specify a class that can be found in the class path, by its file name or with a URL such as `file:///home/user/myproject/src/DocFooter.class`. 21 | 22 | 参数为一到多个 class 文件, 使用空格分隔, 例如 `DocFooter.class`。可以是 class path 中的某个类, 例如文件名或者是文件URL, 如 `file:///home/user/myproject/src/DocFooter.class`。 23 | 24 | 25 | 26 | 27 | ## 说明(Description) 28 | 29 | The `javap` command disassembles one or more class files. The output depends on the options used. When no options are used, then the `javap` command prints the package, protected and public fields, and methods of the classes passed to it. The `javap` command prints its output to `stdout`. 30 | 31 | `javap` 命令展开一个/或多个 class 文件。可以通过命令选项控制输出的具体内容。如果不指定任何选项, 则打印出 package, protected 和 public 字段(fields), 以及参数中指定 class 的方法。 `javap`命令的结果内容输出到 `stdout`。 32 | 33 | 34 | 35 | ## 选项(Options) 36 | 37 | * `-help`, `--help`, `-?` 38 | 打印出 `javap` 命令的帮助信息. 39 | 40 | * `-version` 41 | 打印出 `javap` 命令的版本(release)信息. 42 | * `-l` 43 | 打印出行号(line)以及局部变量表(local variable tables). 44 | * `-public` 45 | 只显示 public 类和成员. 46 | * `-protected` 47 | 只显示 protected/public 类和成员. 48 | * `-private`, `-p` 49 | 显示所有的类和成员(all classes and members). 50 | * `-J_xxxoption_` 51 | 传递给底层JVM的参数. 例如: 52 | ``` 53 | javap -J-version 54 | javap -J-Djava.security.manager -J-Djava.security.policy=MyPolicy MyClassName 55 | ``` 56 | 更多 JVM option 的信息, 请参考 `[java`](05_04_java.md) 命令的官方文档. 57 | * `-s` 58 | 打印内部类型签名(internal type signatures). 59 | * `-sysinfo` 60 | 显示class文件的系统信息(如文件路径(path), 大小(size), 修改日期(date), 以及MD5 hash). 61 | * `-constants` 62 | 显示 `static final` 常量信息. 63 | * `-c` 64 | 打印反编译后的代码(disassembled code), 例如, 以指令(instructions)的方式展示 class 中每个方法的字节码. 65 | * `-verbose` 66 | 打印 stack size, 局部变量number of locals and arguments for methods. 67 | * `-classpath _path_` 68 | 指定 `javap` 命令查找 class 时所使用的 classpath 路径. 如果指定该参数, 则会覆盖默认的系统环境变量 `CLASSPATH` 值. 69 | * `-bootclasspath _path_` 70 | 指定加载 bootstrap 类的路径. 默认情况下, bootstrap classes 从Java安装目录下的 `jre/lib/rt.jar` 以及其他几个 JAR 包中加载. 71 | * `-extdir _dirs_` 72 | 手工指定安装 extensions 的查找目录. 默认 extensions 目录由 `java.ext.dirs` 的值指定. 73 | 74 | 75 | ## 示例 76 | 77 | 下面是 `DocFooter` 类的Java代码: 78 | 79 | ``` 80 | import java.awt.*; 81 | import java.applet.*; 82 | 83 | public class DocFooter extends Applet { 84 | String date; 85 | String email; 86 | 87 | public void init() { 88 | resize(500,100); 89 | date = getParameter("LAST_UPDATED"); 90 | email = getParameter("EMAIL"); 91 | } 92 | 93 | public void paint(Graphics g) { 94 | g.drawString(date + " by ",100, 15); 95 | g.drawString(email,290,15); 96 | } 97 | } 98 | 99 | ``` 100 | 101 | 编译之后, 执行 `javap DocFooter.class` 命令, 结果如下: 102 | 103 | ``` 104 | Compiled from "DocFooter.java" 105 | public class DocFooter extends java.applet.Applet { 106 | java.lang.String date; 107 | java.lang.String email; 108 | public DocFooter(); 109 | public void init(); 110 | public void paint(java.awt.Graphics); 111 | } 112 | 113 | ``` 114 | 115 | 如果加上 `-c` 选项, 执行 `javap -c DocFooter.class` 后结果如下: 116 | 117 | ``` 118 | Compiled from "DocFooter.java" 119 | public class DocFooter extends java.applet.Applet { 120 | java.lang.String date; 121 | java.lang.String email; 122 | 123 | public DocFooter(); 124 | Code: 125 | 0: aload_0 126 | 1: invokespecial #1 // Method 127 | java/applet/Applet."":()V 128 | 4: return 129 | 130 | public void init(); 131 | Code: 132 | 0: aload_0 133 | 1: sipush 500 134 | 4: bipush 100 135 | 6: invokevirtual #2 // Method resize:(II)V 136 | 9: aload_0 137 | 10: aload_0 138 | 11: ldc #3 // String LAST_UPDATED 139 | 13: invokevirtual #4 // Method 140 | getParameter:(Ljava/lang/String;)Ljava/lang/String; 141 | 16: putfield #5 // Field date:Ljava/lang/String; 142 | 19: aload_0 143 | 20: aload_0 144 | 21: ldc #6 // String EMAIL 145 | 23: invokevirtual #4 // Method 146 | getParameter:(Ljava/lang/String;)Ljava/lang/String; 147 | 26: putfield #7 // Field email:Ljava/lang/String; 148 | 29: return 149 | 150 | public void paint(java.awt.Graphics); 151 | Code: 152 | 0: aload_1 153 | 1: new #8 // class java/lang/StringBuilder 154 | 4: dup 155 | 5: invokespecial #9 // Method 156 | java/lang/StringBuilder."":()V 157 | 8: aload_0 158 | 9: getfield #5 // Field date:Ljava/lang/String; 159 | 12: invokevirtual #10 // Method 160 | java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 161 | 15: ldc #11 // String by 162 | 17: invokevirtual #10 // Method 163 | java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder; 164 | 20: invokevirtual #12 // Method 165 | java/lang/StringBuilder.toString:()Ljava/lang/String; 166 | 23: bipush 100 167 | 25: bipush 15 168 | 27: invokevirtual #13 // Method 169 | java/awt/Graphics.drawString:(Ljava/lang/String;II)V 170 | 30: aload_1 171 | 31: aload_0 172 | 32: getfield #7 // Field email:Ljava/lang/String; 173 | 35: sipush 290 174 | 38: bipush 15 175 | 40: invokevirtual #13 // Method 176 | java/awt/Graphics.drawString:(Ljava/lang/String;II)V 177 | 43: return 178 | } 179 | 180 | ``` 181 | 182 | ## 更多信息请参考 183 | 184 | * [`java`(1)](05_04_java.md) 185 | 186 | * [`javac`(1)](javac.html#BHCJCBFB) 187 | 188 | * [`javadoc`(1)](javadoc.html#CHDFCDCI) 189 | 190 | * [`javah`(1)](javah.html#BJECIACA) 191 | 192 | * [`jdb`(1)](jdb.html#CHDFHFDB) 193 | 194 | * [`jdeps`(1)](jdeps.html#BACEHAGD) 195 | 196 | -------------------------------------------------------------------------------- /05_Create_and_Build/README.md: -------------------------------------------------------------------------------- 1 | # 5. Create and Build Applications 2 | 3 | Use the following commands to create and build applications: 4 | 5 | This section contains the following commands: 6 | 7 | 本章介绍应用程序构建相关的命令, 包括: 8 | 9 | 10 | - 5.1 [`appletviewer`](appletviewer.html#BGBJAJHC): Runs applets outside of a web browser. 11 | 12 | - 5.2 [`extcheck`](extcheck.html#CIHJGIJG): Detects version conflicts between a target Java Archive (JAR) file and currently installed extension JAR files. 13 | 14 | - 5.3 [`jar`](jar.html#BGBEJEEG): Combines multiple files into a single JAR file. 15 | 16 | - 5.4 [`java`](05_04_java.md): 启动 Java 程序. 17 | 18 | - 5.5 [`javac`](javac.html#BHCJCBFB): Reads Java class and interface definitions and compiles them into bytecode and class files. 19 | 20 | - 5.6 [`javadoc`](javadoc.html#CHDFCDCI): Generates HTML pages of API documentation from Java source files. 21 | 22 | - 5.7 [`javah`](javah.html#BJECIACA): Generates C header and source files from a Java class. 23 | 24 | - 5.8 [`javap`](05_08_javap.md): 展开(Disassembles)一到多个 `class` 文件. 25 | 26 | - 5.9 [`jdb`](jdb.html#CHDFHFDB): Finds and fixes bugs in Java platform programs. 27 | 28 | - 5.10 [`jdeps`](jdeps.html#BACEHAGD): Java class dependency analyzer 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 原文链接: -------------------------------------------------------------------------------- /06_Security/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/06_Security/README.md -------------------------------------------------------------------------------- /07_Internationalization/README.md: -------------------------------------------------------------------------------- 1 | # 7 Internationalization 2 | 3 | Use these command to create localizable Java applications. 4 | 5 | This section contains the following command: 6 | 7 | native2ascii: Creates localizable applications by converting a file with characters in any supported character encoding to one with ASCII and/or Unicode escapes (\uxxxx) notation for all characters that are not part of the ASCII character set, or vice versa. 8 | 9 | 具体详情请参考: [native2ascii.md](native2ascii.md) 10 | 11 | 12 | 原文链接: [http://docs.oracle.com/javase/8/docs/technotes/tools/windows/s3-internationalizat-tools.html](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/s3-internationalizat-tools.html) 13 | 14 | -------------------------------------------------------------------------------- /07_Internationalization/native2ascii.md: -------------------------------------------------------------------------------- 1 | ## native2ascii 2 | 3 | Creates localizable applications by converting a file with characters in any supported character encoding to one with ASCII and/or Unicode escapes or vice versa. 4 | 5 | ### Synopsis 6 | 7 | native2ascii [ inputfile ] [ outputfile ] 8 | 9 | > inputfile 10 | 11 | The encoded file to be converted to ASCII. 12 | 13 | > outputfile 14 | 15 | The converted ASCII file. 16 | 17 | ### Description 18 | 19 | The native2ascii command converts encoded files supported by the Java Runtime Environment (JRE) to files encoded in ASCII, using Unicode escapes (\uxxxx) notation for all characters that are not part of the ASCII character set. This process is required for properties files that contain characters not in ISO-8859-1 character sets. The tool can also perform the reverse conversion. 20 | 21 | If the outputfile value is omitted, then standard output is used for output. If, in addition, the inputfile value is omitted, then standard input is used for input. 22 | 23 | ### Options 24 | 25 | > -reverse 26 | 27 | Perform the reverse operation: Converts a file encoded in ISO-8859-1 with Unicode escapes to a file in any character encoding supported by the JRE. 28 | 29 | > -encoding encoding_name 30 | 31 | Specifies the name of the character encoding to be used by the conversion procedure. If this option is not present, then the default character encoding (as determined by the java.nio.charset.Charset.defaultCharset method) is used. The encoding_name string must be the name of a character encoding that is supported by the JRE. See Supported Encodings at 32 | http://docs.oracle.com/javase/8/docs/technotes/guides/intl/encoding.doc.html 33 | 34 | > -Joption 35 | 36 | Passes option to the Java Virtual Machine (JVM), where option is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java(1). 37 | 38 | 原文链接: [http://docs.oracle.com/javase/8/docs/technotes/tools/windows/native2ascii.html](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/native2ascii.html) 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /08_RMI/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/08_RMI/README.md -------------------------------------------------------------------------------- /09_Java_IDL_RMI-IIOP/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/09_Java_IDL_RMI-IIOP/README.md -------------------------------------------------------------------------------- /10_Deploy/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/10_Deploy/README.md -------------------------------------------------------------------------------- /11_Java_Web_Start/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/11_Java_Web_Start/README.md -------------------------------------------------------------------------------- /12_Monitor_Java_App/1201.md: -------------------------------------------------------------------------------- 1 | ### jconsole 2 | Starts a graphical console that lets you monitor and manage Java applications. 3 | 4 | Synopsis 5 | jconsole [ options ] [ connection ... ] 6 | 7 | options 8 | The command-line options. See Options. 9 | 10 | connection = pid | host:port | jmxURL 11 | The pid value is the process ID of a local Java Virtual Machine (JVM). The JVM must be running with the same user ID as the user ID running the jconsole command.The host:port values are the name of the host system on which the JVM is running, and the port number specified by the system property com.sun.management.jmxremote.port when the JVM was started.The jmxUrl value is the address of the JMX agent to be connected to as described in JMXServiceURL. 12 | 13 | For more information about the connection parameter, see Monitoring and Management Using JMX Technology at 14 | http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html 15 | 16 | See also the JMXServiceURL class description at 17 | http://docs.oracle.com/javase/8/docs/api/javax/management/remote/JMXServiceURL.html 18 | 19 | Description 20 | The jconsole command starts a graphical console tool that lets you monitor and manage Java applications and virtual machines on a local or remote machine. 21 | 22 | On Windows, the jconsole command does not associate with a console window. It does, however, display a dialog box with error information when the jconsole command fails. 23 | 24 | Options 25 | -interval=n 26 | Sets the update interval to n seconds (default is 4 seconds). 27 | 28 | -notile 29 | Does not tile windows initially (for two or more connections). 30 | 31 | -pluginpath plugins 32 | Specifies a list of directories or JAR files to be searched for JConsole plug-ins. The plugins path should contain a provider-configuration file named META-INF/services/com.sun.tools.jconsole.JConsolePlugin that contains one line for each plug-in. The line specifies the fully qualified class name of the class implementing the com.sun.tools.jconsole.JConsolePlugin class. 33 | 34 | -version 35 | Displays release information and exits. 36 | 37 | -help 38 | Displays a help message. 39 | 40 | -Jflag 41 | Passes flag to the JVM on which the jconsole command is run. 42 | 43 | See Also 44 | Using JConsole at 45 | http://docs.oracle.com/javase/8/docs/technotes/guides/management/jconsole.html 46 | 47 | Monitoring and Management Using JMX Technology at 48 | http://docs.oracle.com/javase/8/docs/technotes/guides/management/agent.html 49 | 50 | The JMXServiceURL class description at 51 | http://docs.oracle.com/javase/8/docs/api/javax/management/remote/JMXServiceURL.html -------------------------------------------------------------------------------- /12_Monitor_Java_App/1202.md: -------------------------------------------------------------------------------- 1 | ### jvisualvm 2 | Visually monitors, troubleshoots, and profiles Java applications. 3 | 4 | Synopsis 5 | jvisualvm [ options ] 6 | 7 | options 8 | The command-line options. See Options. 9 | 10 | Description 11 | Java VisualVM is an intuitive graphical user interface that provides detailed information about Java technology-based applications (Java applications) while they are running on a specified Java Virtual Machine (JVM). The name Java VisualVM comes from the fact that Java VisualVM provides information about the JVM software visually. 12 | 13 | Java VisualVM combines several monitoring, troubleshooting, and profiling utilities into a single tool. For example, most of the functionality offered by the standalone tools jmap, jinfo, jstat, and jstack were integrated into Java VisualVM. Other functionality, such as some that offered by the jconsole command, can be added as optional plug-ins. 14 | 15 | Java VisualVM is useful to Java application developers to troubleshoot applications and to monitor and improve the applications' performance. Java VisualVM enables developers to generate and analyze heap dumps, track down memory leaks, perform and monitor garbage collection, and perform lightweight memory and CPU profiling. You can expand the Java VisualVM functionality with plug-ins. For example, most of the functionality of the jconsole command is available through the MBeans Tab and JConsole Plug-in Wrapper plug-ins. You can choose from a catalog of standard Java VisualVM plug-ins by selecting Tools and then Plugins in the Java VisualVM menus. 16 | 17 | Start Java VisualVM with the following command: 18 | 19 | % jvisualvm 20 | Options 21 | The following option is available when you launch Java VisualVM 22 | 23 | -Jjvm_option 24 | Pass this jvm_option to the JVM software 25 | 26 | See Also 27 | Java VisualVM developer's site 28 | http://visualvm.java.net/ 29 | 30 | Java VisualVM in Java SE documentation 31 | http://docs.oracle.com/javase/8/docs/technotes/guides/visualvm/index.html -------------------------------------------------------------------------------- /12_Monitor_Java_App/README.md: -------------------------------------------------------------------------------- 1 | ##12 Monitor Java Applications 2 | 3 | Use these commands to monitor and manage Java applications. 4 | 5 | 通过这些命令来监控和管理 Java 应用程序. 6 | 7 | This section contains the following commands: 8 | 9 | 本节包括以下命令: 10 | 11 | [jconsole(1)](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jconsole.html#CACDDJCH): Starts a graphical console that lets you monitor and manage Java applications. 12 | 13 | [jconsole](1201.md): 启动图形界面控制台,以监控和管理 Java 应用程序。 14 | 15 | 16 | [jvisualvm(1)](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jvisualvm.html#CBBJCIIB): Visually monitors, troubleshoots, and profiles Java applications. 17 | 18 | [jvisualvm](1202.md): 可视化的Java应用程序监控、故障排除与分析工具。 19 | -------------------------------------------------------------------------------- /13_Monitor_JVM/1301_jps.md: -------------------------------------------------------------------------------- 1 | ## jps 2 | 3 | Lists the instrumented Java Virtual Machines (JVMs) on the target system. This command is experimental and unsupported. 4 | 5 | ### Synopsis 6 | 7 | ``` 8 | jps [ options ] [ hostid ] 9 | ``` 10 | 11 | - **options** 12 | 13 | Command-line options. See Options. 14 | 15 | 16 | - **hostid** 17 | 18 | The identifier of the host for which the process report should be generated. The hostid can include optional components that indicate the communications protocol, port number, and other implementation specific data. See Host Identifier. 19 | 20 | 21 | ### Description 22 | 23 | The `jps` command lists the instrumented Java HotSpot VMs on the target system. The command is limited to reporting information on JVMs for which it has the access permissions. 24 | 25 | 26 | If the `jps` command is run without specifying a hostid, then it searches for instrumented JVMs on the local host. If started with a hostid, then it searches for JVMs on the indicated host, using the specified protocol and port. A jstatd process is assumed to be running on the target host. 27 | 28 | 29 | The `jps` command reports the local JVM identifier, or lvmid, for each instrumented JVM found on the target system. The lvmid is typically, but not necessarily, the operating system's process identifier for the JVM process. With no options, `jps` lists each Java application's lvmid followed by the short form of the application's class name or jar file name. The short form of the class name or JAR file name omits the class's package information or the JAR files path information. 30 | 31 | 32 | The `jps` command uses the Java launcher to find the class name and arguments passed to the main method. If the target JVM is started with a custom launcher, then the class or JAR file name and the arguments to the main method are not available. In this case, the `jps` command outputs the string Unknown for the class name or JAR file name and for the arguments to the main method. 33 | 34 | 35 | The list of JVMs produced by the `jps` command can be limited by the permissions granted to the principal running the command. The command only lists the JVMs for which the principle has access rights as determined by operating system-specific access control mechanisms. 36 | 37 | 38 | ### 选项(Options) 39 | 40 | `jps` 命令支持下面的可选参数,以控制输出的内容。在将来的版本中这些参数可能会被修改或删除。 41 | 42 | **不带参数** 43 | 44 | 示例(以下示例基于 Linux; 在 windows 上的输出可能会更多一些。): 45 | 46 | > `jps` 47 | 48 | ``` 49 | 1103 Bootstrap 50 | 7908 Jps 51 | ``` 52 | 53 | 54 | - **`-q`** 55 | 56 | 在输出中去除 main 方法所在的类名,JAR文件名,及传入的参数。 只输出本地 JVM标识符列表。 57 | 58 | 示例: 59 | 60 | > `jps -q` 61 | 62 | ``` 63 | 1103 64 | 5109 65 | ``` 66 | 67 | 68 | - **`-m`** 69 | 70 | 显示传入 main 方法的参数。某些平台的 JVM 可能会输出 null。 71 | 72 | 73 | 示例: 74 | 75 | > `jps -m` 76 | 77 | ``` 78 | 1103 Bootstrap start 79 | 7960 Jps -m 80 | ``` 81 | 82 | 83 | - **`-l`** 84 | 85 | 显示执行的 main 方法所在类的完整包名,或者是所在 JAR 文件的完整路径。 86 | 87 | 88 | 示例: 89 | 90 | > `jps -l` 91 | 92 | ``` 93 | 1103 org.apache.catalina.startup.Bootstrap 94 | 8270 sun.tools.jps.Jps 95 | ``` 96 | 97 | > `jps -l -m` 98 | 99 | ``` 100 | 1103 org.apache.catalina.startup.Bootstrap start 101 | 8296 sun.tools.jps.Jps -l -m 102 | ``` 103 | 104 | 105 | - **`-v`**(小写的v) 106 | 107 | 显示传入给 JVM 的参数. 108 | 109 | 110 | 示例: 111 | 112 | > `jps -v` 113 | 114 | (为显示方便,已手工折行) 115 | 116 | ``` 117 | 1103 Bootstrap -Djava.util.logging.config.file= 118 | /usr/local/tomcat7/conf/logging.properties 119 | -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 120 | -Djava.endorsed.dirs=/usr/local/tomcat7/endorsed 121 | -Dcatalina.base=/usr/local/tomcat7 122 | -Dcatalina.home=/usr/local/tomcat7 123 | -Djava.io.tmpdir=/usr/local/tomcat7/temp 124 | 8322 Jps -Dapplication.home= 125 | /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.79.x86_64 126 | -Xms8m 127 | ``` 128 | 129 | 130 | - **`-V`**(大写的 **V** ) 131 | 132 | 屏蔽 main 方法所在的类名,JAR文件名,及传入的参数。 只输出本地 JVM标识符列表。(和 **-q** 一样?) 133 | 134 | Suppresses the output of the class name, JAR file name, and arguments passed to the main method, producing only a list of local JVM identifiers. 135 | 136 | 137 | 138 | - **`-Joption`** 139 | 140 | Passes option to the JVM, where option is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m sets the startup memory to 48 MB. See java(1). 141 | 142 | 143 | 144 | ### Host Identifier 145 | 146 | The host identifier, or hostid is a string that indicates the target system. The syntax of the hostid string corresponds to the syntax of a URI: 147 | 148 | 149 | ``` 150 | [protocol:][[//]hostname][:port][/servername] 151 | ``` 152 | 153 | - **protocol** 154 | 155 | The communications protocol. If the protocol is omitted and a hostname is not specified, then the default protocol is a platform-specific, optimized, local protocol. If the protocol is omitted and a host name is specified, then the default protocol is rmi. 156 | 157 | 158 | 159 | - **hostname** 160 | 161 | A hostname or IP address that indicates the target host. If you omit the hostname parameter, then the target host is the local host. 162 | 163 | 164 | 165 | - **port** 166 | 167 | The default port for communicating with the remote server. If the hostname parameter is omitted or the protocol parameter specifies an optimized, local protocol, then the port parameter is ignored. Otherwise, treatment of the port parameter is implementation specific. For the default rmi protocol, the port parameter indicates the port number for the rmiregistry on the remote host. If the port parameter is omitted, and the protocol parameter indicates rmi, then the default rmiregistry port (1099) is used. 168 | 169 | 170 | 171 | - **servername** 172 | 173 | The treatment of this parameter depends on the implementation. For the optimized, local protocol, this field is ignored. For the rmi protocol, this parameter is a string that represents the name of the RMI remote object on the remote host. See the jstatd command -n option for more information. 174 | 175 | 176 | 177 | ### Output Format 178 | 179 | The output of the `jps` command follows the following pattern: 180 | 181 | 182 | ``` 183 | lvmid [ [ classname | JARfilename | "Unknown"] [ arg* ] [ jvmarg* ] ] 184 | ``` 185 | 186 | All output tokens are separated by white space. An arg value that includes embedded white space introduces ambiguity when attempting to map arguments to their actual positional parameters. 187 | 188 | 189 | 190 | **Note**: It is recommended that you do not write scripts to parse `jps` output because the format might change in future releases. If you write scripts that parse `jps` output, then expect to modify them for future releases of this tool. 191 | 192 | 193 | 194 | ### Examples 195 | 196 | This section provides examples of the `jps` command. 197 | 198 | 199 | 200 | List the instrumented JVMs on the local host: 201 | 202 | 203 | ``` 204 | jps 205 | 206 | 18027 Java2Demo.JAR 207 | 18032 jps 208 | 18005 jstat 209 | ``` 210 | 211 | The following example lists the instrumented JVMs on a remote host. This example assumes that the jstat server and either the its internal RMI registry or a separate external rmiregistry process are running on the remote host on the default port (port 1099). It also assumes that the local host has appropriate permissions to access the remote host. This example also includes the -l option to output the long form of the class names or JAR file names. 212 | 213 | 214 | ``` 215 | jps -l remote.domain 216 | 3002 /opt/jdk1.7.0/demo/jfc/Java2D/Java2Demo.JAR 217 | 2857 sun.tools.jstatd.jstatd 218 | ``` 219 | 220 | The following example lists the instrumented JVMs on a remote host with a non-default port for the RMI registry. This example assumes that the jstatd server, with an internal RMI registry bound to port 2002, is running on the remote host. This example also uses the -m option to include the arguments passed to the main method of each of the listed Java applications. 221 | 222 | 223 | ``` 224 | jps -m remote.domain:2002 225 | 226 | 3002 /opt/jdk1.7.0/demo/jfc/Java2D/Java2Demo.JAR 227 | 3102 sun.tools.jstatd.jstatd -p 2002 228 | ``` 229 | 230 | ## See Also 231 | 232 | * [`java`(1)](java.html#CBBFHAJA) 233 | 234 | * [`jstat`(1)](jstat.html#BEHBBBDJ) 235 | 236 | * [`jstatd`(1)](jstatd.html#BABHHDIB) 237 | 238 | * [`rmiregistry`(1)](rmiregistry.html#CHDEDDIE) 239 | 240 | 241 | 242 | 原文链接: 243 | -------------------------------------------------------------------------------- /13_Monitor_JVM/1302_jstat.md: -------------------------------------------------------------------------------- 1 | # jstat 2 | 3 | Monitors Java Virtual Machine (JVM) statistics. This command is experimental and unsupported. 4 | 5 | 监控Java虚拟机(JVM)的统计信息。 jstat命令是实验性质的,官方客服不提供技术支持。 6 | 7 | ## Synopsis 8 | 9 | ## 概述 10 | 11 | 12 | ``` 13 | jstat [ generalOption | outputOptions vmid [ interval[s|ms] [ count ] ] 14 | ``` 15 | 16 | - generalOption 17 | 18 | A single general command-line option -help or -options. See General Options. 19 | 20 | 常规选项,只支持单个,如 `-help` 或者 `-options`。 详细信息请参考下文。 21 | 22 | - outputOptions 23 | 24 | One or more output options that consist of a single `statOption`, plus any of the `-t`, `-h`, and `-J` options. See [Output Options](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jstat.html#BEHIGDGJ). 25 | 26 | 输出选项, 可包含单个 `statOption`,加上任意数量的 `-t`,`-h` 和 `-J` 选项。 详细信息请参考下文。 27 | 28 | - vmid 29 | 30 | Virtual machine identifier, which is a string that indicates the target JVM. The general syntax is the following: 31 | 32 | 虚拟机标识符(virtual machine identifier),是一个字符串, 用于明确指示目标JVM。 一般语法如下: 33 | 34 | `[protocol:][//]lvmid[@hostname[:port]/servername] ` 35 | 36 | The syntax of the `vmid` string corresponds to the syntax of a URI. The `vmid` string can vary from a simple integer that represents a local JVM to a more complex construction that specifies a communications protocol, port number, and other implementation-specific values. See [Virtual Machine Identifier](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jstat.html#BEHBCGCA). 37 | 38 | `vmid`字符串的语法类似于URI。 可以是一个数字,表示本地JVM; 或者是由多个部分组成的复杂结构:通信协议,端口号,以及其他特定实现相关的值。 详细信息请参考下文。 39 | 40 | - interval [s|ms] 41 | 42 | Sampling interval in the specified units, seconds (s) or milliseconds (ms). Default units are milliseconds. Must be a positive integer. When specified, the `jstat` command produces its output at each interval. 43 | 44 | 采样间隔时间, 指定以秒(s)或毫秒(ms)为单位。 默认单位是毫秒, 必须是正整数。 如果指定该参数,则`jstat`命令以这个时间间隔输出新的内容。 45 | 46 | - count 47 | 48 | Number of samples to display. The default value is infinity which causes the `jstat` command to display statistics until the target JVM terminates or the `jstat` command is terminated. This value must be a positive integer. 49 | 50 | 要输出的采样次数, 必须是正整数值。 默认值为无穷大(infinity),也就是 `jstat` 命令会持续输出统计信息,直到目标JVM关闭, 或者`jstat`命令终止。 51 | 52 | ## Description 53 | 54 | ## 说明 55 | 56 | The `jstat` command displays performance statistics for an instrumented Java HotSpot VM. The target JVM is identified by its virtual machine identifier, or `vmid` option. 57 | 58 | `jstat` 可以输出一个HotSpot虚拟机的性能统计信息。 目标JVM由其虚拟机标识符,或者`vmid`选项来标识。 59 | 60 | 61 | 62 | ## Virtual Machine Identifier 63 | 64 | ## 虚拟机标识符 65 | 66 | The syntax of the `vmid` string corresponds to the syntax of a URI: 67 | 68 | `vmid`字符串的语法类似于URI: 69 | 70 | ``` 71 | [protocol:][//]lvmid[@hostname[:port]/servername] 72 | ``` 73 | 其中, 74 | 75 | - protocol 76 | 77 | The communications protocol. If the *protocol* value is omitted and a host name is not specified, then the default protocol is a platform-specific optimized local protocol. If the *protocol* value is omitted and a host name is specified, then the default protocol is `rmi`. 78 | 79 | 通信协议。 如果省略这个值, 也不指定主机名(host name),则默认协议则是该平台的本地优化协议(optimized local protocol)。 如果省略 *protocol* 值但指定了主机名,则默认协议为 `rmi`。 80 | 81 | - lvmid 82 | 83 | The local virtual machine identifier for the target JVM. The `lvmid` is a platform-specific value that uniquely identifies a JVM on a system. The `lvmid` is the only required component of a virtual machine identifier. The `lvmid` is typically, but not necessarily, the operating system's process identifier for the target JVM process. You can use the `jps` command to determine the `lvmid`. Also, you can determine the `lvmid` on Solaris, Linux, and OS X platforms with the `ps` command, and on Windows with the Windows Task Manager. 84 | 85 | 目标JVM所在机器内部的本地虚拟机标识符(local virtual machine identifier)。 `lvmid` 唯一地标识了操作系统中的一个JVM,各格平台可能不一样。 `lvmid`是虚拟机标识符的唯一必需组件。 `lvmid`通常是目标JVM进程的进程号(但可能有例外)。 86 | 87 | 我们可以使用 `jps` 命令来确定 `lvmid`。 在Solaris,Linux和OS X平台上还可以使用 `ps` 命令来确定`lvmid`,在Windows上系统中可以使用任务管理器查看 `lvmid`。 88 | 89 | - hostname 90 | 91 | A hostname or IP address that indicates the target host. If the *hostname* value is omitted, then the target host is the local host. 92 | 93 | 主机名, 可以是目标主机的域名或IP地址。 如果省略 *hostname* 值,则目标主机就是本机。 94 | 95 | - port 96 | 97 | The default port for communicating with the remote server. If the *hostname* value is omitted or the *protocol* value specifies an optimized, local protocol, then the *port* value is ignored. Otherwise, treatment of the `port` parameter is implementation-specific. For the default `rmi`protocol, the port value indicates the port number for the rmiregistry on the remote host. If the *port* value is omitted and the *protocol* value indicates `rmi`, then the default rmiregistry port (1099) is used. 98 | 99 | 与远程服务器通信的默认端口。 100 | 101 | 如果省略*hostname*值, 或者指定 *protocol* 为本地优化协议,则会忽略 *port* 值。 102 | 103 | 否则,`port`参数的默认值由具体平台确定。 如果是默认的`rmi`协议,则表示远程主机上 rmiregistry(rmi注册服务)的端口号。 如果省略 *port* 并且协议为`rmi`,则使用rmiregistry的默认端口号(1099)。 104 | 105 | - servername 106 | 107 | The treatment of the `servername` parameter depends on implementation. For the optimized local protocol, this field is ignored. For the `rmi` protocol, it represents the name of the RMI remote object on the remote host. 108 | 109 | `servername`参数的处理取决于实现。 本地优化协议会忽略此字段。 `rmi`协议下则表示远程主机上,RMI远程对象的名称。 110 | 111 | 112 | 113 | 114 | 115 | ## Options 116 | 117 | ## 命令选项 118 | 119 | The `jstat` command supports two types of options, general options and output options. General options cause the `jstat` command to display simple usage and version information. Output options determine the content and format of the statistical output. 120 | 121 | `jstat`命令支持两种类型的选项,常规选项和输出选项。 常规选项只用于显示简单的用法和版本信息。 输出选项决定了输出的内容/格式。 122 | 123 | All options and their functionality are subject to change or removal in future releases. 124 | 125 | 所有选项和功能,在新版本的JDK中,都有可能会发生更改/删除。 126 | 127 | 128 | 129 | ### General Options 130 | 131 | ### 常规选项(General Options) 132 | 133 | 134 | If you specify one of the general options, then you cannot specify any other option or parameter. 135 | 136 | 如果指定了一个常规选项,则不能再指定其他选项。 137 | 138 | - `-help` 139 | 140 | Displays a help message. 141 | 142 | 显示帮助消息。 143 | 144 | - `-options` 145 | 146 | Displays a list of static options. See Output Options. 147 | 148 | 输出支持的选项(options)。 详细信息请参考下文。 149 | 150 | 使用示例: 151 | 152 | ``` 153 | jstat 154 | jstat -help 155 | jstat -options 156 | ``` 157 | 158 | 只有第一个常规选项有效, 后面的被忽略: 159 | 160 | ``` 161 | jstat -help -options -gc 0000 162 | jstat -options -help -gc 0000 163 | ``` 164 | 165 | 166 | ### Output Options 167 | 168 | ### 输出选项(Output Options) 169 | 170 | If you do not specify a general option, then you can specify output options. Output options determine the content and format of the `jstat` command's output, and consist of a single `statOption`, plus any of the other output options (`-h`, `-t`, and `-J`). The `statOption` must come first. 171 | 172 | 如果不指定常规选项,则可以指定输出选项。 输出选项决定了输出的内容/格式,由单个`statOption`部分,加上其他输出选项(`-h`,`-t`和`-J`)组成。 而且`statOption`必须放在前面。 173 | 174 | Output is formatted as a table, with columns that are separated by spaces. A header row with titles describes the columns. Use the `-h` option to set the frequency at which the header is displayed. Column header names are consistent among the different options. In general, if two options provide a column with the same name, then the data source for the two columns is the same. 175 | 176 | 输出被格式化为表格(table),两列之间由空格分隔。 标题行描述了各个列的信息。 使用 `-h` 选项设置标题行出现的频率。 每个列的标题,在各种输出选项中都是一致的。 一般来说,如果两个输出选项的列具有相同的名称,那么这两列的数据来源就是一样的。 177 | 178 | Use the `-t` option to display a time stamp column, labeled Timestamp as the first column of output. The Timestamp column contains the elapsed time, in seconds, since the target JVM started. The resolution of the time stamp is dependent on various factors and is subject to variation due to delayed thread scheduling on heavily loaded systems. 179 | 180 | 使用`-t`选项,在第一列加上时间戳列,列名为Timestamp。 Timestamp列是目标JVM启动后经历的时间(以秒为单位)。 时间戳的精度可能受各种因素的影响,比如在负载很高的机器上, 线程调度造成的延迟可能就不一致。 181 | 182 | Use the interval and count parameters to determine how frequently and how many times, respectively, the `jstat` command displays its output. 183 | 184 | interval 参数决定了 `jstat` 命令输出的频率, count 参数决定了 `jstat` 命令输出的次数。 185 | 186 | **Note:** Do not to write scripts to parse the `jstat` command's output because the format might change in future releases. If you write scripts that parse `jstat` command output, then expect to modify them for future releases of this tool. 187 | 188 | **官方警告:** 最好不要编写脚本来解析`jstat`命令的输出,因为在将来的JDK版本中可能会发生改变。 如果已经编写了解析脚本,那么最好也为新版本的JDK做好修改的准备。 蕴含的意思是说,最好花钱买JDK11以后提供的全家桶工具包。 189 | 190 | 191 | - **-statOption** 192 | 193 | Determines the statistics information the jstat command displays. The following lists the available options. Use the -options general option to display the list of options for a particular platform installation. See Stat Options and Output. 194 | 195 | 统计选项决定了 jstat 命令输出哪些统计信息。可以使用常规选项 `-options` 查看支持的选项。 详细信息请参考下文。下面是可用的统计选项列表。 196 | 197 | `class`: Displays statistics about the behavior of the class loader. 198 | 199 | `class`: 显示 class loader 相关的统计信息。 示例: `jstat -class 21891` 200 | 201 | `compiler`: Displays statistics about the behavior of the Java HotSpot VM Just-in-Time compiler. 202 | 203 | `compiler`: 显示即时编译器(Just-in-Time)相关的统计信息。 204 | 205 | `gc`: Displays statistics about the behavior of the garbage collected heap. 206 | 207 | `gc`: 显示堆内存与GC相关的统计信息。这里的信息不包含各个内存池的最大容量。 208 | 209 | `gccapacity`: Displays statistics about the capacities of the generations and their corresponding spaces. 210 | 211 | `gccapacity`: 显示有关各个内存池相关的统计信息。 212 | 213 | `gccause`: Displays a summary about garbage collection statistics (same as -gcutil), with the cause of the last and current (when applicable) garbage collection events. 214 | 215 | `gccause`: 显示垃圾收集相关的汇总统计信息(与 `-gcutil` 类似),但在最后面加上,上次GC的原因(LGCC), 和当前GC的原因(GCC, 如果处于GC过程中的话)。 示例: `jstat -gccause -h 5 21891 5s` 216 | 217 | `gcnew`: Displays statistics of the behavior of the new generation. 218 | 219 | `gcnew`: 显示新生代(new generations)行为相关的统计信息。 220 | 221 | `gcnewcapacity`: Displays statistics about the sizes of the new generations and its corresponding spaces. 222 | 223 | `gcnewcapacity`: 显示新生代(new generations)和相关空间大小的统计信息。 224 | 225 | `gcold`: Displays statistics about the behavior of the old generation and metaspace statistics. 226 | 227 | `gcold`: 显示老年代和metaspace内存空间相关的统计信息。 228 | 229 | `gcoldcapacity`: Displays statistics about the sizes of the old generation. 230 | 231 | `gcoldcapacity`: 显示老年代内存空间大小相关的统计信息。 232 | 233 | `gcmetacapacity`: Displays statistics about the sizes of the metaspace. 234 | 235 | `gcmetacapacity`: 显示 metaspace 内存空间大小相关的统计信息。 236 | 237 | `gcuti`l: Displays a summary about garbage collection statistics. 238 | 239 | `gcuti`l: 显示垃圾收集相关的汇总统计信息. 240 | 241 | `printcompilation`: Displays Java HotSpot VM compilation method statistics. 242 | 243 | `printcompilation`: 显示 Java HotSpot VM 方法编译相关的统计信息。 244 | 245 | 246 | - `-h n` 247 | 248 | Displays a column header every *n* samples (output rows), where *n* is a positive integer. Default value is 0, which displays the column header the first row of data. 249 | 250 | 每隔n行数据,打印一次列标题,其中*n*是一个正整数。 默认值为0,只在第一行显示列标题。 251 | 252 | - `-t` 253 | 254 | Displays a timestamp column as the first column of output. The time stamp is the time since the start time of the target JVM. 255 | 256 | 在第一列加上时间戳列,列名为Timestamp。 Timestamp列是目标JVM启动后经历的时间(以秒为单位) 257 | 258 | - `-JjavaOption` 259 | 260 | Passes `javaOption` to the Java application launcher. For example, `-J-Xms48m` sets the startup memory to 48 MB. For a complete list of options, see [`java`(1)](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#CBBFHAJA). 261 | 262 | 将JVM启动参数 `javaOption` 传递给应用启动程序. 例如, `-J-Xms48m` 将初始内存设置为 48 MB. 完整的JVM启动参数列表请参考Java命令. 263 | 264 | 265 | 266 | ### Stat Options and Output 267 | 268 | ### 统计选项和输出内容 269 | 270 | 271 | The following information summarizes the columns that the `jstat` command outputs for each *statOption*. 272 | 273 | 下面汇总了每个统计选项(statOption)的输出列。 274 | 275 | - `-class` *option* 276 | 277 | - `-class`选项 278 | 279 | Class loader statistics. 280 | 281 | 类加载(Class loader)信息统计. 282 | 283 | `Loaded`: Number of classes loaded. 284 | 285 | `Loaded`: 已加载的 class 数量. 286 | 287 | `Bytes`: Number of kBs loaded. 288 | 289 | `Bytes`: 已加载的字节数. 290 | 291 | `Unloaded`: Number of classes unloaded. 292 | 293 | `Unloaded`: 已卸载(unloaded)的 class 数量. 294 | 295 | `Bytes`: Number of Kbytes unloaded. 296 | 297 | `Bytes`: 已卸载的字节数. 298 | 299 | `Time`: Time spent performing class loading and unloading operations. 300 | 301 | `Time`: 执行类加载与类卸载所消耗的时间. 302 | 303 | - `-compiler` *option* 304 | 305 | - `-compiler`选项 306 | 307 | Java HotSpot VM Just-in-Time compiler statistics. 308 | 309 | Java HotSpot VM 即时编译器(Just-in-Time)相关的统计信息。 310 | 311 | `Compiled`: Number of compilation tasks performed. 312 | 313 | `Compiled`: 已执行的编译任务数。 314 | 315 | `Failed`: Number of compilations tasks failed. 316 | 317 | `Failed`: 编译任务失败数量. 318 | 319 | `Invalid`: Number of compilation tasks that were invalidated. 320 | 321 | `Invalid`: 无效的编译任务数量. 322 | 323 | `Time`: Time spent performing compilation tasks. 324 | 325 | `Time`: 执行编译任务花费的总时间. 326 | 327 | `FailedType`: Compile type of the last failed compilation. 328 | 329 | `FailedType`: 最后一次编译失败的编译类型. 330 | 331 | `FailedMethod`: 最后一次编译失败的Class名称与方法 332 | 333 | - `-gc` *option* 334 | 335 | - `-gc`选项 336 | 337 | Garbage-collected heap statistics. 338 | 339 | 垃圾收集相关的堆内存信息. 示例用法: `jstat -gc -h 10 -t 21891 1s` 340 | 341 | `S0C`: Current survivor space 0 capacity (kB). 342 | 343 | `S0C`: 存活区S0的当前容量(capacity), 单位 kB. 344 | 345 | `S1C`: Current survivor space 1 capacity (kB). 346 | 347 | `S1C`: 存活区S1的当前容量(capacity), 单位 kB. 348 | 349 | `S0U`: Survivor space 0 utilization (kB). 350 | 351 | `S0U`: 存活区S0的使用量(utilization), 单位 kB. 352 | 353 | `S1U`: Survivor space 1 utilization (kB). 354 | 355 | `S1U`: 存活区S1的使用量(utilization), 单位 kB. 356 | 357 | `EC`: Current eden space capacity (kB). 358 | 359 | `EC`: 新生代(Eden区)的当前容量(capacity), 单位 kB. 360 | 361 | `EU`: Eden space utilization (kB). 362 | 363 | `EU`: 新生代(Eden区)的使用量(utilization), 单位 kB. 364 | 365 | `OC`: Current old space capacity (kB). 366 | 367 | `OC`: 老年代(old space)的当前容量(capacity), 单位 kB. 368 | 369 | `OU`: Old space utilization (kB). 370 | 371 | `OU`: 老年代(old space)的使用量(utilization), 单位 kB. 372 | 373 | `MC`: Metaspace capacity (kB). 374 | 375 | `MC`: 元数据区(Metaspace)的容量(capacity), 单位 kB. 376 | 377 | `MU`: Metacspace utilization (kB). 378 | 379 | `MU`: 元数据区(Metaspace)的使用量(utilization), 单位 kB. 380 | 381 | `CCSC`: Compressed class space capacity (kB). 382 | 383 | `CCSC`: 压缩的class空间(Compressed class space)容量, 单位 kB. 384 | 385 | `CCSU`: Compressed class space used (kB). 386 | 387 | `CCSU`: 压缩的class空间(Compressed class space)使用量, 单位 kB. 388 | 389 | `YGC`: Number of young generation garbage collection events. 390 | 391 | `YGC`: 年轻代GC(young generation)的次数。 392 | 393 | `YGCT`: Young generation garbage collection time. 394 | 395 | `YGCT`: 年轻代GC消耗的总时间。 396 | 397 | `FGC`: Number of full GC events. 398 | 399 | `FGC`: Full GC 的次数 400 | 401 | `FGCT`: Full garbage collection time. 402 | 403 | `FGCT`: Full GC 消耗的时间. 404 | 405 | `GCT`: Total garbage collection time. 406 | 407 | `GCT`: 垃圾收集消耗的总时间。 408 | 409 | - `-gccapacity` *option* 410 | 411 | - `-gccapacity`选项 412 | 413 | Memory pool generation and space capacities. 414 | 415 | 内存池分代与各个空间的容量。示例用法: `jstat -gccapacity -h 10 -t 21891 1s` 416 | 417 | `NGCMN`: Minimum new generation capacity (kB). 418 | 419 | `NGCMN`: 年轻代的最小容量, 单位 kB. 420 | 421 | `NGCMX`: Maximum new generation capacity (kB). 422 | 423 | `NGCMX`: 年轻代的最大容量, 单位 kB. 424 | 425 | `NGC`: Current new generation capacity (kB). 426 | 427 | `NGC`: 年轻代的当前容量, 单位 kB. 428 | 429 | `S0C`: Current survivor space 0 capacity (kB). 430 | 431 | `S0C`: 存活区S0的当前容量(capacity), 单位 kB. 432 | 433 | `S1C`: Current survivor space 1 capacity (kB). 434 | 435 | `S1C`: 存活区S1的当前容量(capacity), 单位 kB. 436 | 437 | `EC`: Current eden space capacity (kB). 438 | 439 | `EC`: 新生代(Eden区)的当前容量(capacity), 单位 kB. 440 | 441 | `OGCMN`: Minimum old generation capacity (kB). 442 | 443 | `OGCMN`: 老年代允许的最小容量, 单位 kB. 444 | 445 | `OGCMX`: Maximum old generation capacity (kB). 446 | 447 | `OGCMX`: 老年代的最大容量, 单位 kB. 448 | 449 | `OGC`: Current old generation capacity (kB). 450 | 451 | `OGC`: 此刻老年代空间的大小, 单位 kB. 452 | 453 | `OC`: Current old space capacity (kB). 454 | 455 | `OC`: 老年代(old space)的当前容量(capacity), 单位 kB. 456 | 457 | `MCMN`: Minimum metaspace capacity (kB). 458 | 459 | `MCMN`: 元数据区(Metaspace)的最小容量, 单位 kB. 460 | 461 | `MCMX`: Maximum metaspace capacity (kB). 462 | 463 | `MCMX`: 元数据区(Metaspace)的最大容量, 单位 kB. 464 | 465 | `MC`: Metaspace capacity (kB). 466 | 467 | `MC`: 元数据区(Metaspace)的容量(capacity), 单位 kB. 468 | 469 | `CCSMN`: Compressed class space minimum capacity (kB). 470 | 471 | `CCSMN`: 压缩的class空间(Compressed class space)的最小容量, 单位 kB. 472 | 473 | `CCSMX`: Compressed class space maximum capacity (kB). 474 | 475 | `CCSMX`: 压缩的class空间(Compressed class space)的最大容量, 单位 kB. 476 | 477 | `CCSC`: Compressed class space capacity (kB). 478 | 479 | `CCSC`: 压缩的class空间(Compressed class space)容量, 单位 kB. 480 | 481 | `YGC`: Number of young generation GC events. 482 | 483 | `YGC`: 年轻代GC(young generation)的次数。 484 | 485 | `FGC`: Number of full GC events. 486 | 487 | `FGC`: Full GC 的次数 488 | 489 | - `-gccause` *option* 490 | 491 | - `-gccause`选项 492 | 493 | This option displays the same summary of garbage collection statistics as the `-gcutil` option, but includes the causes of the last garbage collection event and (when applicable) the current garbage collection event. In addition to the columns listed for `-gcutil`, this option adds the following columns. 494 | 495 | 此选项展示垃圾收集相关区域的统计信息, 和 `-gcutil` 选项(gc相关使用率)的输出基本一致,但多了上次GC事件的原因(`LGCC`), 以及本次GC(如果正在GC中)的原因。 本选项比`-gcutil`选项多出的列: 496 | 497 | `LGCC`: Cause of last garbage collection 498 | 499 | `LGCC`: 上次GC事件的原因 500 | 501 | `GCC`: Cause of current garbage collection 502 | 503 | `GCC`: 本次GC的原因 504 | 505 | - `-gcnew` *option* 506 | 507 | - `-gcnew`选项 508 | 509 | New generation statistics. 510 | 511 | 年轻代的统计信息. (New = Eden + S0 + S1) 512 | 513 | `S0C`: Current survivor space 0 capacity (kB). 514 | 515 | `S0C`: 存活区S0的当前容量(capacity), 单位 kB. 516 | 517 | `S1C`: Current survivor space 1 capacity (kB). 518 | 519 | `S1C`: 存活区S1的当前容量(capacity), 单位 kB. 520 | 521 | `S0U`: Survivor space 0 utilization (kB). 522 | 523 | `S0U`: 存活区S0的使用量(utilization), 单位 kB. 524 | 525 | `S1U`: Survivor space 1 utilization (kB). 526 | 527 | `S1U`: 存活区S1的使用量(utilization), 单位 kB. 528 | 529 | `TT`: Tenuring threshold. 530 | 531 | `TT`: 晋升阈值(Tenuring threshold). 532 | 533 | `MTT`: Maximum tenuring threshold. 534 | 535 | `MTT`: 最大晋升阈值. 536 | 537 | `DSS`: Desired survivor size (kB). 538 | 539 | `DSS`: 期望的存活区大小, 单位 kB. 540 | 541 | `EC`: Current eden space capacity (kB). 542 | 543 | `EC`: 新生代(Eden区)的当前容量(capacity), 单位 kB. 544 | 545 | `EU`: Eden space utilization (kB). 546 | 547 | `EU`: 新生代(Eden区)的使用量(utilization), 单位 kB. 548 | 549 | `YGC`: Number of young generation GC events. 550 | 551 | `YGC`: 年轻代GC(young generation)的次数。 552 | 553 | `YGCT`: Young generation garbage collection time. 554 | 555 | `YGCT`: 年轻代GC消耗的总时间。 556 | 557 | 558 | - `-gcnewcapacity` *option* 559 | 560 | - `-gcnewcapacity`选项 561 | 562 | New generation space size statistics. 563 | 564 | 年轻代空间大小统计. 565 | 566 | `NGCMN`: Minimum new generation capacity (kB). 567 | 568 | `NGCMN`: 年轻代的最小容量, 单位 kB. 569 | 570 | `NGCMX`: Maximum new generation capacity (kB). 571 | 572 | `NGCMX`: 年轻代的最大容量, 单位 kB. 573 | 574 | `NGC`: Current new generation capacity (kB). 575 | 576 | `NGC`: 年轻代的当前容量, 单位 kB. 577 | 578 | `S0CMX`: Maximum survivor space 0 capacity (kB). 579 | 580 | `S0CMX`: 存活区S0的最大容量, 单位 kB. 581 | 582 | `S0C`: Current survivor space 0 capacity (kB). 583 | 584 | `S0C`: 存活区S0的当前容量(capacity), 单位 kB. 585 | 586 | `S1CMX`: Maximum survivor space 1 capacity (kB). 587 | 588 | `S1CMX`: 存活区S1的最大容量, 单位 kB. 589 | 590 | `S1C`: Current survivor space 1 capacity (kB). 591 | 592 | `S1C`: 存活区S1的当前容量(capacity), 单位 kB. 593 | 594 | `ECMX`: Maximum eden space capacity (kB). 595 | 596 | `ECMX`: 新生代(eden区)的最大容量, 单位 kB. 597 | 598 | `EC`: Current eden space capacity (kB). 599 | 600 | `EC`: 新生代(Eden区)的当前容量(capacity), 单位 kB. 601 | 602 | `YGC`: Number of young generation GC events. 603 | 604 | `YGC`: 年轻代GC(young generation)的次数。 605 | 606 | `FGC`: Number of full GC events. 607 | 608 | `FGC`: Full GC 的次数 609 | 610 | 611 | - `-gcold` *option* 612 | 613 | - `-gcold`选项 614 | 615 | Old generation and metaspace behavior statistics. 616 | 617 | 老年代和元数据区的行为统计。 618 | 619 | `MC`: Metaspace capacity (kB). 620 | 621 | `MC`: 元数据区(Metaspace)的容量(capacity), 单位 kB. 622 | 623 | `MU`: Metaspace utilization (kB). 624 | 625 | `MU`: 元数据区(Metaspace)的使用量(utilization), 单位 kB. 626 | 627 | `CCSC`: Compressed class space capacity (kB). 628 | 629 | `CCSC`: 压缩的class空间(Compressed class space)容量, 单位 kB. 630 | 631 | `CCSU`: Compressed class space used (kB). 632 | 633 | `CCSU`: 压缩的class空间(Compressed class space)使用量, 单位 kB. 634 | 635 | `OC`: Current old space capacity (kB). 636 | 637 | `OC`: 老年代(old space)的当前容量(capacity), 单位 kB. 638 | 639 | `OU`: Old space utilization (kB). 640 | 641 | `OU`: 老年代(old space)的使用量(utilization), 单位 kB. 642 | 643 | `YGC`: Number of young generation GC events. 644 | 645 | `YGC`: 年轻代GC(young generation)的次数。 646 | 647 | `FGC`: Number of full GC events. 648 | 649 | `FGC`: Full GC 的次数 650 | 651 | `FGCT`: Full garbage collection time. 652 | 653 | `FGCT`: Full GC 消耗的时间. 654 | 655 | `GCT`: Total garbage collection time. 656 | 657 | `GCT`: 垃圾收集消耗的总时间。 658 | 659 | 660 | - `-gcoldcapacity` *option* 661 | 662 | - `-gcoldcapacity`选项 663 | 664 | Old generation size statistics. 665 | 666 | 老年代空间大小统计. 667 | 668 | `OGCMN`: Minimum old generation capacity (kB). 669 | 670 | `OGCMN`: 老年代允许的最小容量, 单位 kB. 671 | 672 | `OGCMX`: Maximum old generation capacity (kB). 673 | 674 | `OGCMX`: 老年代的最大容量, 单位 kB. 675 | 676 | `OGC`: Current old generation capacity (kB). 677 | 678 | `OGC`: 此刻老年代空间的大小, 单位 kB. 679 | 680 | `OC`: Current old space capacity (kB). 681 | 682 | `OC`: 老年代(old space)的当前容量(capacity), 单位 kB. 683 | 684 | `YGC`: Number of young generation GC events. 685 | 686 | `YGC`: 年轻代GC(young generation)的次数。 687 | 688 | `FGC`: Number of full GC events. 689 | 690 | `FGC`: Full GC 的次数 691 | 692 | `FGCT`: Full garbage collection time. 693 | 694 | `FGCT`: Full GC 消耗的时间. 695 | 696 | `GCT`: Total garbage collection time. 697 | 698 | `GCT`: 垃圾收集消耗的总时间。 699 | 700 | 701 | - `-gcmetacapacity` *option* 702 | 703 | - `-gcmetacapacity`选项 704 | 705 | Metaspace size statistics. 706 | 707 | 元数据区大小统计. 708 | 709 | `MCMN`: Minimum metaspace capacity (kB). 710 | 711 | `MCMN`: 元数据区(Metaspace)的最小容量, 单位 kB. 712 | 713 | `MCMX`: Maximum metaspace capacity (kB). 714 | 715 | `MCMX`: 元数据区(Metaspace)的最大容量, 单位 kB. 716 | 717 | `MC`: Metaspace capacity (kB). 718 | 719 | `MC`: 元数据区(Metaspace)的容量(capacity), 单位 kB. 720 | 721 | `CCSMN`: Compressed class space minimum capacity (kB). 722 | 723 | `CCSMN`: 压缩的class空间(Compressed class space)的最小容量, 单位 kB. 724 | 725 | `CCSMX`: Compressed class space maximum capacity (kB). 726 | 727 | `CCSMX`: 压缩的class空间(Compressed class space)的最大容量, 单位 kB. 728 | 729 | `YGC`: Number of young generation GC events. 730 | 731 | `YGC`: 年轻代GC(young generation)的次数。 732 | 733 | `FGC`: Number of full GC events. 734 | 735 | `FGC`: Full GC 的次数 736 | 737 | `FGCT`: Full garbage collection time. 738 | 739 | `FGCT`: Full GC 消耗的时间. 740 | 741 | `GCT`: Total garbage collection time. 742 | 743 | `GCT`: 垃圾收集消耗的总时间。 744 | 745 | 746 | - `-gcutil` *option* 747 | 748 | - `-gcutil`选项 749 | 750 | Summary of garbage collection statistics. 751 | 752 | 垃圾收集相关区域的使用率(utilization)统计。 753 | 754 | `S0`: Survivor space 0 utilization as a percentage of the space's current capacity. 755 | 756 | `S0`: 存活区S0, 当前使用量/当前容量, 单位是百分比(%). 757 | 758 | `S1`: Survivor space 1 utilization as a percentage of the space's current capacity. 759 | 760 | `S1`: 存活区S1, 当前使用量/当前容量, 单位是百分比(%). 761 | 762 | `E`: Eden space utilization as a percentage of the space's current capacity. 763 | 764 | `E`: Eden区(新生代), 当前使用量/当前容量, 单位是百分比(%). 765 | 766 | `O`: Old space utilization as a percentage of the space's current capacity. 767 | 768 | `O`: 老年代, 当前使用量/当前容量, 单位是百分比(%). 769 | 770 | `M`: Metaspace utilization as a percentage of the space's current capacity. 771 | 772 | `M`: Meta区, 当前使用量/当前容量, 单位是百分比(%). 773 | 774 | `CCS`: Compressed class space utilization as a percentage. 775 | 776 | `CCS`: 压缩的class空间(Compressed class space)的使用率, 百分比. 777 | 778 | `YGC`: Number of young generation GC events. 779 | 780 | `YGC`: 年轻代GC(young generation)的次数。 781 | 782 | `YGCT`: Young generation garbage collection time. 783 | 784 | `YGCT`: 年轻代GC消耗的总时间。 785 | 786 | `FGC`: Number of full GC events. 787 | 788 | `FGC`: Full GC 的次数 789 | 790 | `FGCT`: Full garbage collection time. 791 | 792 | `FGCT`: Full GC 消耗的时间. 793 | 794 | `GCT`: Total garbage collection time. 795 | 796 | `GCT`: 垃圾收集消耗的总时间。 797 | 798 | 799 | - `-printcompilation` *option* 800 | 801 | - `-printcompilation`选项 802 | 803 | Java HotSpot VM compiler method statistics. 804 | 805 | JVM(HotSpot)编译方法统计。 806 | 807 | `Compiled`: Number of compilation tasks performed by the most recently compiled method. 808 | 809 | `Compiled`: 最近使用的编译方法,已执行的编译任务数。 810 | 811 | `Size`: Number of bytes of byte code of the most recently compiled method. 812 | 813 | `Size`: 最近使用的编译方法,编译的字节码数量(字节数). 814 | 815 | `Type`: Compilation type of the most recently compiled method. 816 | 817 | `Type`: 最近使用的编译方法,执行的编译类型 818 | 819 | `Method`: Class name and method name identifying the most recently compiled method. Class name uses slash (/) instead of dot (.) as a name space separator. Method name is the method within the specified class. The format for these two fields is consistent with the HotSpot `-XX:+PrintCompilation` option. 820 | 821 | `Method`: 标识最近编译方法的类名(Class name)和方法名(method name)。 类名的分隔符使用左斜杠(/)代替点号(.)。 方法名就是指定类中的方法。 这两个字段的格式与JVM启动参数 `-XX:+PrintCompilation` 的格式一致。 822 | 823 | 824 | 825 | 826 | 827 | 828 | 829 | ## Examples 830 | 831 | ## jstat使用示例 832 | 833 | This section presents some examples of monitoring a local JVM with an *lvmid* of 21891. 834 | 835 | 下面的示例,假设监控的是本地的JVM, `lvmid`(进程号) 为 `21891`。 836 | 837 | 838 | ### The gcutil Option 839 | 840 | ### `gcutil` 选项示例 841 | 842 | This example attaches to lvmid 21891 and takes 7 samples at 250 millisecond intervals and displays the output as specified by the `-gcutil` option. 843 | 844 | 下面用 jstat 连到lvmid为 21891的JVM,以250毫秒的间隔进行7次采样,指定输出选项为 `-gcutil`。 845 | 846 | 847 | ``` 848 | jstat -gcutil 21891 250 7 849 | S0 S1 E O M CCS YGC YGCT FGC FGCT GCT 850 | 0.00 97.02 70.31 66.80 95.52 89.14 7 0.300 0 0.000 0.300 851 | 0.00 97.02 86.23 66.80 95.52 89.14 7 0.300 0 0.000 0.300 852 | 0.00 97.02 96.53 66.80 95.52 89.14 7 0.300 0 0.000 0.300 853 | 91.03 0.00 1.98 68.19 95.89 91.24 8 0.378 0 0.000 0.378 854 | 91.03 0.00 15.82 68.19 95.89 91.24 8 0.378 0 0.000 0.378 855 | 91.03 0.00 17.80 68.19 95.89 91.24 8 0.378 0 0.000 0.378 856 | 91.03 0.00 17.80 68.19 95.89 91.24 8 0.378 0 0.000 0.378 857 | ``` 858 | 859 | The output of this example shows that a young generation collection occurred between the third and fourth sample. The collection took 0.078 seconds and promoted objects from the eden space (E) to the old space (O), resulting in an increase of old space utilization from 66.80% to 68.19%. Before the collection, the survivor space was 97.02% utilized, but after this collection it is 91.03% utilized. 860 | 861 | 从输出可以看出, 在第三个和第四个样本之间, 发生了一次年轻代GC。 这次GC耗时0.078秒,并将部分对象从年轻代提升到老年代, 导致老年代空间的使用率从66.80% 上升到 68.19%。 在GC之前, 存活区的使用率为 97.02%,但GC之后,存活区的使用率为 91.03%。 862 | 863 | 864 | 865 | ### Repeat the Column Header String 866 | 867 | ### 每N行后输出一次标题行 868 | 869 | This example attaches to lvmid 21891 and takes samples at 250 millisecond intervals and displays the output as specified by `-gcnew` option. In addition, it uses the `-h3` option to output the column header after every 3 lines of data. 870 | 871 | 下面用 jstat 连到lvmid为 21891的JVM,以250毫秒的间隔进行7次采样, 指定输出选项为 `-gcnew`。 此外,通过 `-h3` 选项指定每3行数据后输出一次标题行。 872 | 873 | 874 | 875 | ``` 876 | jstat -gcnew -h3 21891 250 877 | 878 | S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 879 | 64.0 64.0 0.0 31.7 31 31 32.0 512.0 178.6 249 0.203 880 | 64.0 64.0 0.0 31.7 31 31 32.0 512.0 355.5 249 0.203 881 | 64.0 64.0 35.4 0.0 2 31 32.0 512.0 21.9 250 0.204 882 | S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 883 | 64.0 64.0 35.4 0.0 2 31 32.0 512.0 245.9 250 0.204 884 | 64.0 64.0 35.4 0.0 2 31 32.0 512.0 421.1 250 0.204 885 | 64.0 64.0 0.0 19.0 31 31 32.0 512.0 84.4 251 0.204 886 | S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT 887 | 64.0 64.0 0.0 19.0 31 31 32.0 512.0 306.7 251 0.204 888 | ``` 889 | 890 | In addition to showing the repeating header string, this example shows that between the second and third samples, a young GC occurred. Its duration was 0.001 seconds. The collection found enough active data that the survivor space 0 utilization (S0U) would have exceeded the desired survivor Size (DSS). As a result, objects were promoted to the old generation (not visible in this output), and the tenuring threshold (TT) was lowered from 31 to 2. 891 | 892 | 除了重复标题行增加可读性之外,此示例还表明,在第二个和第三个样本之间,发生了一个年轻代GC, 持续时间为0.001秒。 GC发现有了足够的活跃数据,存活区S0的使用量(S0U)超过了期望的存活区大小(DSS)。 结果是有一部分对象被提升到老年代(在此输出中看不到),并且晋升阈值(TT)从31降到2。 893 | 894 | Another collection occurs between the fifth and sixth samples. This collection found very few survivors and returned the tenuring threshold to 31. 895 | 896 | 另一次GC发生在第五和第六次采样期间。 这次GC发现存活对象很少,将晋升阈值恢复到31。 897 | 898 | 899 | 900 | ### Include a Time Stamp for Each Sample 901 | 902 | ### 在每个样本前面加上时间戳 903 | 904 | This example attaches to lvmid 21891 and takes 3 samples at 250 millisecond intervals. The `-t` option is used to generate a time stamp for each sample in the first column. 905 | 906 | 下面用 jstat 连到lvmid为 21891的JVM,以250毫秒的间隔进行3次采样, 指定输出选项为 `-gcnew`。 `-t`选项用于为第一列中的每个样本生成时间戳。 907 | 908 | 909 | ``` 910 | jstat -gcoldcapacity -t 21891 250 911 | 912 | 913 | Timestamp OGCMN OGCMX OGC OC YGC FGC FGCT GCT 914 | 150.1 1408.0 60544.0 11696.0 11696.0 194 80 2.874 3.799 915 | 150.4 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863 916 | 150.7 1408.0 60544.0 13820.0 13820.0 194 81 2.938 3.863 917 | ``` 918 | 919 | 920 | The Timestamp column reports the elapsed time in seconds since the start of the target JVM. In addition, the `-gcoldcapacity` output shows the old generation capacity (OGC) and the old space capacity (OC) increasing as the heap expands to meet allocation or promotion demands. The old generation capacity (OGC) has grown from 11,696 kB to 13,820 kB after the eighty-first full garbage collection (FGC). The maximum capacity of the generation (and space) is 60,544 kB (OGCMX), so it still has room to expand. 921 | 922 | Timestamp列显示了自目标JVM启动以来经过的时间(以秒为单位)。 此外,指定输出选项为 `-gcoldcapacity`, 用于显示老年代的容量(OGC), 以及老年空间的容量(OC), 都随着堆内存的扩展而变大。 在第81次 FGC 后,老年代的容量(OGC)从 11,696 kB 增长到了 13,820 kB。 老年代空间允许的最大值为 60,544 kB(OGCMX),因此还有扩展空间。 923 | 924 | 925 | 926 | ### Monitor Instrumentation for a Remote JVM 927 | 928 | ### 监视远程JVM 929 | 930 | This example attaches to lvmid 40496 on the system named remote.domain using the `-gcutil` option, with samples taken every second indefinitely. 931 | 932 | 下面用 jstat 连到remote.domain机器上,lvmid为 40496 的JVM, 指定输出选项为 `-gcutil` 。每秒钟生成一次样本, 持续时间不限制。 933 | 934 | 935 | 936 | ``` 937 | jstat -gcutil 40496@remote.domain 1000 938 | ... output omitted 939 | ``` 940 | 941 | The lvmid is combined with the name of the remote host to construct a *vmid* of `40496@remote.domain`. This vmid results in the use of the `rmi` protocol to communicate to the default `jstatd` server on the remote host. The `jstatd` server is located using the `rmiregistry`command on `remote.domain` that is bound to the default port of the `rmiregistry` command (port 1099). 942 | 943 | `40496@remote.domain` 表示在这台机器上, lvmid为 40496,这个vmid串使用默认的 `rmi` 协议, 连接到远程主机上 `jstatd`服务器的默认端口。 `jstatd` 通过 `rmiregistry` 命令监听 `remote.domain`,默认端口是(1099)。 944 | 945 | 946 | 947 | 948 | 949 | 950 | See Also 951 | 952 | 另请参阅 953 | 954 | 955 | - [`java`](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/java.html#CBBFHAJA) 956 | 957 | - [`jps`](./1301_jps.md) 958 | 959 | - [`jstatd`](./1303_jstatd.md) 960 | 961 | - [`rmiregistry`](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/rmiregistry.html#CHDEDDIE) 962 | 963 | 原文链接: 964 | 965 | -------------------------------------------------------------------------------- /13_Monitor_JVM/1303_jstatd.md: -------------------------------------------------------------------------------- 1 | # 13.3 jstatd 2 | 3 | 监控本地JVM, 允许远程监控工具连接到本机的JVM。该命令尚处于实验阶段,官方不提供技术支持。 4 | 5 | 6 | ## 用法 7 | 8 | **jstatd** [ _options_ ]`_options_` 9 | 10 | 命令行选项参数。请参考下方的 [选项(Options)](#options) 部分。 11 | 12 | ## jstatd简介 13 | 14 | `jstatd` 是一个RMI服务器程序, 用来监控 Java HotSpot VM 的启动和关闭, 并提供接口, 允许远程监控客户端连接服务器本地运行的JVM实例。 15 | 16 | 17 | `jstatd` 服务端需要本机存在 RMI注册服务(RMI registry)。在 `jstatd` 服务启动时,会尝试连接默认的RMI注册端口, 当然, 也可以通过 `-p port_num` 选项来指定这个端口号。如果没有找到RMI注册服务, 则会自动创建一个内置的 RMI注册服务, 端口号通过 `-p` 参数指定, 不指定则使默认值。如果不想创建 RMI注册服务, 可以通过 `-nr` 选项启动。 18 | 19 | 20 | ## 选项(Options) 21 | 22 | * `-nr` 23 | 如果没有找到RMI注册服务, 禁止 `jstatd` 在进程内创建RMI注册服务。 24 | 25 | * `-p _port_` 26 | 指定该端口号来查询RMI注册服务, 如果没有找到, 则默认会使用该端口号来创建(指定 `-nr` 选项则不创建)。 27 | 28 | * `-n rminame` 29 | 绑定到RMI注册服务的 remote RMI object 名称。默认名称为 `JStatRemoteHost`。如果需要在同一台机器上启动多个 `jstatd` 服务, 则需要通过该选项来指定唯一名称. 当然, 指定名称后, 客户端连接时需要对应的 `hostid` 和 `vmid`。 30 | 31 | * `-J_option_` 32 | 传递给底层JVM的 `option`, 这类选项就是JVM启动参数。例如, `-J-Xms48m` 就表示设置启动内存为 `48MB`。详情请参考 [`java`]() 命令。 33 | 34 | 35 | ## 安全问题(Security) 36 | 37 | `jstatd`服务器,只能监控启动该服务的用户权限范围内的JVM实例。因此, `jstatd` 进程必须和要监控的目标JVM使用相同的用户权限启动. 在某些系统, 例如 Solaris,Linux和OS X操作系统中, root 用户可以访问所有的JVM。所以用 root 权限启动 `jstatd` 则可以监控系统上运行的所有JVM, 但这样又容易引起一些安全问题。 38 | 39 | `jstatd`服务器对远程客户端不进行任何身份校验。因此, 启动 `jstatd` 服务器会将所有的jvm暴露给网络上的任意用户。在某些环境中这是不可取的, 因此, 在启动 `jstatd` 进程之前应指定本地安全策略(local security policies), 特别是在生产环境或者不安全的网络环境中(如公网)。 40 | 41 | 如果没有安装其他的安全管理器, 则`jstatd`服务器会安装一个 `RMISecurityPolicy` 实例, 因此,需要指定一个安全策略文件(security policy file)。策略文件必须符合默认的 Policy 实现规范, 以及 Policy 文件语法格式。 参考: 42 | 43 | 44 | 下面的策略文件, 允许 `jstatd` 服务器不抛出任何安全性异常. 该策略比授予所有代码权限要严格, 却又比最小权限要宽松很多。 45 | 46 | ``` 47 | grant codebase "file:${java.home}/../lib/tools.jar" { 48 | permission java.security.AllPermission; 49 | }; 50 | 51 | ``` 52 | 53 | 54 | 要使用这种策略, 将其中的文本粘贴到文件 `jstatd.all.policy` 之中, 并在启动 `jstatd` 时指定如下选项: 55 | 56 | ``` 57 | jstatd -J-Djava.security.policy=/xxxPath/jstatd.all.policy 58 | 59 | ``` 60 | 61 | 62 | 需要更强安全措施的网站, 可以自定义策略文件, 用以限制客户端只能是特定的受信主机或某些网段, 尽管这些技术可能受到IP地址欺骗技术的攻击。如果不能通过定制的策略文件解决安全问题, 那么最好不要启动 `jstatd` 服务, 只能在服务器本地使用 `jstat` 和 `jps` 工具。 63 | 64 | 65 | ## 远程接口 66 | 67 | `jstatd` 服务提供的接口是专用的, 随时可能发生变化, 不建议用户和开发者操作这些接口。 68 | 69 | 70 | ## 示例 71 | 72 | 下面是 `jstatd` 命令的使用示例。这些脚本会自动在后台启动 `jstatd` 服务。 73 | 74 | 75 | ### 内置的RMI注册服务 76 | 77 | 以下示例展示了如何启动 `jstatd` 以及内置的RMI注册服务. 这里假定没有其他服务绑定到默认的RMI注册端口 (默认 `1099`)。 78 | 79 | ``` 80 | jstatd -J-Djava.security.policy=all.policy 81 | 82 | ``` 83 | 84 | ### 外部RMI注册服务 85 | 86 | 以下示例演示如何使用外部RMI注册服务来启动 `jstatd`。 87 | 88 | ``` 89 | rmiregistry & 90 | jstatd -J-Djava.security.policy=all.policy 91 | ``` 92 | 93 | > rmiregistry 监听了 1099端口, jstatd尝试连接该端口, 成功则不会创建内置的RMI注册服务。 94 | 95 | 以下示例, 展示了在端口2020上启动外部RMI注册服务, 并启动`jstatd`。 96 | 97 | ``` 98 | jrmiregistry 2020 & 99 | jstatd -J-Djava.security.policy=all.policy -p 2020 100 | 101 | ``` 102 | 103 | > rmiregistry 监听了 2020 端口, jstatd尝试连接 2020 端口, 成功则不会创建内置的RMI注册服务。 104 | 105 | 106 | 以下示例, 展示了在端口2020上启动外部RMI注册服务, 并启动`jstatd`, 同时指定了 remote RMI object 的名称为 `AlternateJstatdServerName`。 107 | 108 | ``` 109 | rmiregistry 2020& 110 | jstatd -J-Djava.security.policy=all.policy -p 2020 111 | -n AlternateJstatdServerName 112 | 113 | ``` 114 | 115 | 116 | ### 禁止创建进程内置的RMI注册服务 117 | 118 | 以下示例启动 `jstatd` 服务时,禁止创建进程内置的RMI注册服务。 即使没有现成的RMI注册服务, 也不准自动创建。 如果没有 RMI注册服务, 则启动失败, 并显示错误信息。 119 | 120 | ``` 121 | jstatd -J-Djava.security.policy=all.policy -nr 122 | 123 | ``` 124 | 125 | 126 | ### 启用 RMI 日志记录 127 | 128 | 129 | 以下示例启动 `jstatd` 服务, 并启用 RMI日志记录功能。日志功能对于监控服务器行为, 以及故障排除来说非常有用。 130 | 131 | ``` 132 | jstatd -J-Djava.security.policy=all.policy 133 | -J-Djava.rmi.server.logCalls=true 134 | 135 | ``` 136 | 137 | 138 | ## 另请参阅 139 | 140 | * [`java`(1)](java.html#CBBFHAJA) 141 | * [`jps`](1301_jps.md) 142 | * [`jstat`](1302_jstat.md) 143 | * [`rmiregistry`(1)](rmiregistry.html#CHDEDDIE) 144 | 145 | 146 | 原文链接: 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /13_Monitor_JVM/1304_jmc.md: -------------------------------------------------------------------------------- 1 | ## 13.4 jmc 2 | 3 | Java指挥中心(Java Mission Control) 是一款用于对 Java 应用程序进行管理、监视、概要分析和故障排除的工具套件。 4 | 5 | ### 简介(Synopsis) 6 | 7 | > jmc [ options ] 8 | 9 | 如果使用参数(Options), 则直接在命令(command name) 后面加上. 参数不分顺序. 更多细节信息,请查看下方的 [Options](#options). 10 | 11 | ### 说明(Description) 12 | 13 | > **Note**: 如果用在商业产品之中, 则需要购买 Java Mission Control 的商业许可. 如需了解更多,请参考: [http://www.oracle.com/technetwork/java/javaseproducts/](http://www.oracle.com/technetwork/java/javaseproducts/). 14 | 15 | 16 | Java Mission Control 是用于对 HotSpot JVM 生产环境进行分析和诊断的工具. 首次安装时,Java Mission Control 包括 JMX 控制台(Management Console)和 Java 飞行记录器(Java Flight Recorder), 也可以安装更多插件, 但需要下载. Java Mission Control 也可以作为插件集成到 Eclipse IDE 之中. 17 | 18 | ###Options 19 | 20 | 启动 Java Mission Control 时可用下列参数: 21 | 22 | >**-help** 23 | 24 | 打印出 jmc 的命令行帮助信息(经测试没什么用,图形界面,直接点帮助菜单) 25 | 26 | >**-version** 27 | 28 | 显示出 Java Mission Control 的版本号,然后程序退出. 29 | 30 | >**-showversion** 31 | 32 | 显示出 Java Mission Control 的版本号,不退出,正常打开.(经测试没什么用,图形界面,直接点帮助菜单) 33 | 34 | >**-debug** 35 | 36 | 启用 debug 输出. 37 | 38 | >**-consoleLog** 39 | 40 | 在控制台窗口中打印出 Eclipse log. 从 Eclipse 来的标志(Flag from Eclipse). 41 | 42 | 在 Windows 上, 此选项的效果使用下面的命令来完成(经测试会打打开额外的一个 Console): 43 | 44 | JAVA_HOME\bin\jmc.exe -consoleLog 2>&1 | more 45 | 46 | > **-data workspace** 47 | 48 | 指定 Java Mission Control 的 workspace. 默认的 workspace 是 `$HOME/.jmc` 目录. (Flag from Eclipse). 49 | 50 | >**-open file** 51 | 52 | 在 Java Mission Control 中打开文件. 例如, 打开飞行记录文件(Flight Recording file, 后缀 `.jfr`). 53 | 54 | >**eclipse-option** 55 | 56 | 将 eclipse option 透传给底层的 Eclipse platform. 例如. `-nosplash` 57 | 58 | >**-vmargs jvm-arguments** 59 | 60 | 覆盖 `JAVA_HOME/bin` 目录下 `jmc.ini` 文件中定义的 JVM 参数. 61 | 62 | >**--launcher.appendVmargs** 63 | 64 | 除 jmc.ini 文件中定义的 `-vmargs` 标志外附加的 JVM 参数. 65 | 66 | ## 另请参见(See Also) 67 | 68 | JavaSE 高级知识与工具: [http://www.oracle.com/us/technologies/java/standard-edition/advanced-suite/overview/index.html](http://www.oracle.com/us/technologies/java/standard-edition/advanced-suite/overview/index.html) 69 | 70 | Java Mission Control 用户指南: [http://docs.oracle.com/javacomponents/jmc.htm](http://docs.oracle.com/javacomponents/jmc.htm) 71 | 72 | 73 | -------------------------------------------------------------------------------- /13_Monitor_JVM/README.md: -------------------------------------------------------------------------------- 1 | # 13. JVM监控 2 | 3 | 下面的命令用来监视和管理Java虚拟机(JVM)。但官方大多不对这些命令提供技术支持/客服, 部分处于实验阶段, 在未来的JDK版本中不一定存在。 4 | 5 | 6 | 这些命令包括: 7 | 8 | - [`jps`](1301_jps.md): 尚处于实验阶段。 列出在目标机器上可见的(如同一个用户的),正在运行的JVM。 9 | - [`jstat`](1302_jstat.md): 尚处于实验阶段。 监控Java虚拟机统计数据。 10 | - [`jstatd`](1303_jstatd.md): 尚处于实验阶段。 监控Java虚拟机,使得远程监控工具可以连接到本机的JVM。 11 | - [`jmc`](1304_jmc.md): 启动 Java Mission Controla 工具, 用来监控和管理Java应用以及JVM。 12 | 13 | 14 | 15 | 16 | 原文链接: 17 | 18 | -------------------------------------------------------------------------------- /14_Web_Services/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/14_Web_Services/README.md -------------------------------------------------------------------------------- /15_Troubleshooting/README.md: -------------------------------------------------------------------------------- 1 | # 15 Troubleshooting 2 | 3 | # 15 故障排查工具 4 | 5 | Use these commands to troubleshoot Java applications and the Java Virtual Machine (JVM). Most of these commands are unsupported and experimental and might not be available in future JDK releases. 6 | 7 | 故障排查工具用于对Java应用和Java虚拟机(JVM)进行故障排除。 这些命令中的大多数都是实验性质的,官方不提供技术支持,在未来的JDK版本中还有可能不再内置。 8 | 9 | This section contains the following commands: 10 | 11 | 包含以下命令: 12 | 13 | [`jcmd`](jcmd.md): Sends diagnostic command requests to a running JVM. 14 | 15 | [`jinfo`](jinfo.md): Experimental. Generates configuration information. 16 | 17 | [`jhat`](jhat.md): Experimental. Analyzes the Java heap. 18 | 19 | [`jmap`](jmap.md): Experimental. Prints shared object memory maps or heap memory details for a process, core file, or remote debug server. 20 | 21 | [`jsadebugd`](jsadebugd.md): Experimental. Attaches to a Java process or core file and acts as a debug server. 22 | 23 | [`jstack`](jstack.md): Experimental. Prints Java thread stack traces for a Java process, core file, or remote debug server. 24 | 25 | ---- 26 | 27 | [`jcmd`](jcmd.md): 将诊断命令发送给正在运行中的JVM。 28 | 29 | [`jinfo`](jinfo.md): 实验性质的工具。 生成配置信息。 30 | 31 | [`jhat`](jhat.md): 实验性质的工具。 分析Java堆。 32 | 33 | [`jmap`](jmap.md): 实验性质的工具。 为进程、核心文件或远程debug服务器打印输出共享对象内存映射或堆内存详细信息。 34 | 35 | [`jsadebugd`](jsadebugd.md): 实验性质的工具。 附加到Java进程或核心文件,并充当调试服务器。 36 | 37 | [`jstack`](jstack.md): 实验性质的工具。 为Java进程,核心文件或远程调试服务器打印输出Java线程栈跟踪信息。 38 | 39 | 原文地址: 40 | -------------------------------------------------------------------------------- /15_Troubleshooting/jcmd.md: -------------------------------------------------------------------------------- 1 | ## jcmd 2 | 3 | ## JDK内置故障排查工具: jcmd 简介 4 | 5 | Sends diagnostic command requests to a running Java Virtual Machine (JVM). 6 | 7 | 将诊断命令发送给正在运行中的Java虚拟机(JVM)。 8 | 9 | 10 | ### Synopsis 11 | 12 | ### 用法(Synopsis) 13 | 14 | ``` 15 | jcmd [-l|-h|-help] 16 | 17 | jcmd pid|main-class PerfCounter.print 18 | 19 | jcmd pid|main-class -f filename 20 | 21 | jcmd pid|main-class 22 | ``` 23 | 24 | 25 | ### Description 26 | 27 | ### 详细说明 28 | 29 | The `jcmd` utility is used to send diagnostic command requests to the JVM. It must be used on the same machine on which the JVM is running, and have the same effective user and group identifiers that were used to launch the JVM. 30 | 31 | `jcmd`工具用于将诊断命令发送到JVM。 必须与目标JVM的同一台机器上才能使用, 并且和JVM必须是相同的启动用户,相同的用户组。 32 | 33 | 34 | > **Note:** To invoke diagnostic commands from a remote machine or with different identifiers, you can use the `com.sun.management.DiagnosticCommandMBean` interface. For more information about the `DiagnosticCommandMBean` interface, see the API documentation at `http://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/DiagnosticCommandMBean.html` 35 | 36 | > **注意:** 如果要从远程机器或者不同的用户组来执行诊断命令,可以使用 `com.sun.management.DiagnosticCommandMBean` 接口。 更多关于 `DiagnosticCommandMBean`接口的信息,请参阅API文档: 。 37 | 38 | If you run `jcmd` without arguments or with the `-l` option, it prints the list of running Java process identifiers with the main class and command-line arguments that were used to launch the process. Running `jcmd` with the `-h` or `-help` option prints the tool's help message. 39 | 40 | 如果 `jcmd` 不带参数或者是 `-l` 选项,则会打印出正在运行的Java进程信息, 包括进程标识(pid), main class, 以及命令行启动参数。 使用 `-h` 或`-help` 选项则会打印出帮助消息。 41 | 42 | > **Note:** The `jcmd` utility can be used to dynamically interact with Java Flight Recorder (JFR) in a JVM that is already running. You can use it to unlock commercial features, enable/start/stop flight recordings, and obtain various status messages from the system. For a list of examples, see the Java Flight Recorder Runtime Guide at `http://docs.oracle.com/javacomponents/jmc.htm` 43 | 44 | > **注意:** `jcmd` 工具可以和JVM中的Java Flight Recorder(JFR)动态交互。 可以用它来解锁商业功能,enable/start/stop 飞行记录仪, 从系统获中取各种状态消息。 有关示例请参阅Java Flight Recorder 运行时指南: 。 45 | 46 | If you specify the processes identifier (*pid*) or the main class (*main-class*) as the first argument, `jcmd` sends the diagnostic command request to the Java process with the specified identifier or to all Java processes with the specified name of the main class. You can also send the diagnostic command request to all available Java processes by specifying `0` as the process identifier. Use one of the following as the diagnostic command request: 47 | 48 | 如果第一个参数是进程标识符(`pid`)或者主类(`main-class`), `jcmd`将诊断命令发送给对应pid的Java进程,或者发送给对应main-class的所有Java进程。 还可以将进程标识符指定为 `0`, 把诊断命令发送给所有可见的Java进程。 每个诊断命令可以是下面列表中的一项: 49 | 50 | - `Perfcounter.print` 51 | 52 | Prints the performance counters available for the specified Java process. The list of performance counters might vary with the Java process. 53 | 54 | 打印指定Java进程的性能计数器。 每个Java进程的性能计数器列表可能都不一样。 55 | 56 | 示例: 57 | 58 | ``` 59 | sudo jcmd 12560 PerfCounter.print 60 | 61 | 12560: 62 | java.property.java.version="1.8.0_74" 63 | sun.gc.cause="No GC" 64 | sun.gc.tlab.alloc=66264539 65 | sun.gc.tlab.allocThreads=53 66 | sun.gc.tlab.gcWaste=574925 67 | sun.gc.tlab.maxGcWaste=56861 68 | sun.gc.tlab.maxSlowAlloc=169 69 | sun.gc.tlab.maxSlowWaste=1987 70 | sun.rt.createVmBeginTime=1557804656707 71 | sun.rt.createVmEndTime=1557804657789 72 | sun.rt.javaCommand="org.apache.catalina.startup.Bootstrap start" 73 | sun.rt.vmInitDoneTime=1557804656802 74 | ...... 75 | ``` 76 | 77 | - `-f ` 78 | 79 | The name of the file from which to read diagnostic commands and send them to the specified Java process. Used only with the `-f` option. Each command in the file must be written on a single line. Lines starting with a number sign (`#`) are ignored. Processing of the file ends when all lines have been read or when a line containing the `stop` keyword is read. 80 | 81 | 从文件中读取诊断命令并将其发送到指定的Java进程。 仅当第一个参数是进程标识符或主类时,才能使用此选项。 82 | 对应文件中的每个命令都必须写在单独的一行。 83 | 以井号(`#`)开头的行是注释,将被忽略。 84 | 当所有行读取完毕、或者某一行包含`stop`关键字时,文件处理就结束。 85 | 86 | - `` 87 | 88 | The command to be sent to the specified Java process. The list of available diagnostic commands for a given process can be obtained by sending the `help` command to this process. Each diagnostic command has its own set of arguments. To see the description, syntax, and a list of available arguments for a command, use the name of the command as the argument for the `help` command. 89 | 90 | **Note:** If any arguments contain spaces, you must surround them with single or double quotation marks (`'` or `"`). In addition, you must escape single or double quotation marks with a backslash (`\`) to prevent the operating system shell from processing quotation marks. Alternatively, you can surround these arguments with single quotation marks and then with double quotation marks (or with double quotation marks and then with single quotation marks). 91 | 92 | 要发送到指定Java进程的命令。 93 | 可以向此进程发送 `help` 命令来获取可用的诊断命令列表。 94 | 每个诊断命令都有自己的参数集。 95 | 要查看某个命令的具体信息和用法,请使用 `help XXX命令` 的方式来查看。 96 | 97 | **注意:** 如果某个参数包含空格,则必须用单引号或双引号(`'` or `"`)引起来。 此外,还必须使用反斜杠(`\`)将单引号和双引号转义,避免操作系统shell将引号给吃掉。 或者,也可以将参数用单引号引起来, 再在外面用双引号引起来(也可以里面用双引号,外层用单引号,shell只吃掉一层)。 98 | 99 | 示例: 100 | 101 | ``` 102 | # sudo jcmd 12560 help VM.flags 103 | # sudo jcmd 12560 VM.flags 104 | sudo jcmd 12560 help 105 | 106 | 12560: 107 | The following commands are available: 108 | JFR.stop 109 | JFR.start 110 | JFR.dump 111 | JFR.check 112 | VM.native_memory 113 | VM.check_commercial_features 114 | VM.unlock_commercial_features 115 | ManagementAgent.stop 116 | ManagementAgent.start_local 117 | ManagementAgent.start 118 | GC.rotate_log 119 | Thread.print 120 | GC.class_stats 121 | GC.class_histogram 122 | GC.heap_dump 123 | GC.run_finalization 124 | GC.run 125 | VM.uptime 126 | VM.flags 127 | VM.system_properties 128 | VM.command_line 129 | VM.version 130 | help 131 | 132 | For more information about a specific command use 'help '. 133 | ``` 134 | 135 | ### Options 136 | 137 | ### 选项(Options) 138 | 139 | Options are mutually exclusive. 140 | 141 | 各个选项是互斥的。 142 | 143 | - `-f ` 144 | 145 | Reads commands from the specified file. This option can be used only if you specify the process identifier or the main class as the first argument. Each command in the file must be written on a single line. Lines starting with a number sign (`#`) are ignored. Processing of the file ends when all lines have been read or when a line containing the `stop` keyword is read. 146 | 147 | 从指定文件中读取命令。 仅当第一个参数是进程标识符或主类时,才能使用此选项。 148 | 对应文件中的每个命令都必须写在单独的一行。 149 | 以井号(`#`)开头的行是注释,将被忽略。 150 | 当所有行读取完毕、或者某一行包含`stop`关键字时,文件处理就结束。 151 | 152 | 153 | - `-h` 154 | 155 | - `-help` 156 | 157 | Prints a help message. 158 | 159 | 显示帮助信息. 160 | 161 | 示例: 162 | 163 | ``` 164 | # jcmd -help 165 | jcmd -h 166 | Usage: jcmd 167 | or: jcmd -l 168 | or: jcmd -h 169 | 170 | command must be a valid jcmd command for the selected jvm. 171 | Use the command "help" to see which commands are available. 172 | If the pid is 0, commands will be sent to all Java processes. 173 | The main class argument will be used to match (either partially 174 | or fully) the class used to start Java. 175 | If no options are given, lists Java processes (same as -p). 176 | 177 | PerfCounter.print display the counters exposed by this process 178 | -f read and execute commands from the file 179 | -l list JVM processes on the local machine 180 | -h this help 181 | ``` 182 | 183 | - `-l` 184 | 185 | Prints the list of running Java processes identifiers with the main class and command-line arguments. 186 | 187 | 打印出正在运行的Java进程信息, 包括进程标识(pid), main class, 以及命令行启动参数。 188 | 189 | 示例: 190 | 191 | ``` 192 | # sudo jcmd -l | grep -v jcmd 193 | sudo jcmd -l 194 | 195 | 2760 org.apache.catalina.startup.Bootstrap start 196 | 7689 sun.tools.jcmd.JCmd -l 197 | 1083 org.apache.catalina.startup.Bootstrap start 198 | ``` 199 | 200 | 201 | ### See Also 202 | 203 | ### 另请参见 204 | 205 | - [jps](../13_Monitor_JVM/1301_jps.md) 206 | 207 | -------------------------------------------------------------------------------- /15_Troubleshooting/jhat.md: -------------------------------------------------------------------------------- 1 | ## jhat 2 | 3 | ## JDK内置故障排查工具: jhat 简介 4 | 5 | 6 | Analyzes the Java heap. This command is experimental and unsupported. 7 | 8 | Java Heap(dump文件)分析工具; 此工具为实验性质、官方不提供技术支持。 9 | 10 | 11 | ### Synopsis 12 | 13 | ### 用法 14 | 15 | ``` 16 | jhat [ options ] heap-dump-file 17 | ``` 18 | 19 | - *heap-dump-file* 20 | 21 | Java binary heap dump file to be browsed. For a dump file that contains multiple heap dumps, you can specify which dump in the file by appending `#` to the file name, for example, `myfile.hprof#3`. 22 | 23 | 要查看的二进制Java堆转储文件(Java binary heap dump file)。 如果某个转储文件中包含了多份 heap dumps, 可在文件名之后以 `#` 的方式指定解析哪一个 dump, 如: `myfile.hprof#3` 24 | 25 | 26 | ### 示例 ## 27 | 28 | 使用jmap工具转储堆内存、可以使用如下方式: 29 | 30 | ``` 31 | jmap -dump:file=DumpFileName.txt,format=b 32 | ``` 33 | 34 | 例如: 35 | 36 | ``` 37 | jmap -dump:file=D:/javaDump.hprof,format=b 3614 38 | Dumping heap to D:\javaDump.hprof ... 39 | Heap dump file created 40 | ``` 41 | 42 | 其中, 3614 是java进程的ID,一般来说, jmap 需要和目标JVM的版本一致或者兼容,才能成功导出. 如果不知道如何使用,直接输入 `jmap`, 或者 `jmap -h` 可看到提示信息. 43 | 44 | 然后分析时使用jhat命令,如下所示: 45 | 46 | ``` 47 | jhat -J-Xmx1024m D:/javaDump.hprof 48 | ...... 其他信息 ... 49 | Snapshot resolved. 50 | Started HTTP server on port 7000 51 | Server is ready. 52 | ``` 53 | 54 | 使用参数 `-J-Xmx1024m` 是因为默认JVM的堆内存可能不足以加载整个dump 文件. 可根据需要进行调整. 根据提示知道端口号是 7000, 55 | 56 | 接着使用浏览器访问 即可看到相关信息. 57 | 58 | 59 | ### Description 60 | 61 | ### 详细说明 62 | 63 | The `jhat` command parses a Java heap dump file and starts a web server. The `jhat` command lets you to browse heap dumps with your favorite web browser. The `jhat` command supports predesigned queries such as show all instances of a known class `MyClass`, and Object Query Language (OQL). OQL is similar to SQL, except for querying heap dumps. Help on OQL is available from the OQL help page shown by the `jhat` command. With the default port, OQL help is available at http://localhost:7000/oqlhelp/ 64 | 65 | `jhat`命令解析堆转储文件, 并启动 web server. 然后可以通过浏览器来查看/浏览 dump 出来的 heap. `jhat` 命令支持预定义的查询, 例如显示某个类的所有实例. 还支持 **对象查询语言**(OQL, Object Query Language)。 OQL有点类似SQL,专门用来查询堆转储。 OQL相关的帮助信息可以在 jhat 命令所提供的服务器页面最底部. 如果使用默认端口, 则OQL帮助信息页面为: 66 | 67 | 68 | There are several ways to generate a Java heap dump: 69 | 70 | 生成JVM堆转储文件(heap dump)的方式有多种: 71 | 72 | - Use the `jmap -dump` option to obtain a heap dump at runtime. See [`jmap`(1)](./jmap.md) 73 | 74 | - 使用 `jmap -dump` 选项获取JVM运行时的堆转储. (可以参考上面的示例)详情参见: [`jmap`(1)](./jmap.md) 75 | 76 | - Use the `jconsole` option to obtain a heap dump through `HotSpotDiagnosticMXBean` at runtime. See [`jconsole`(1)](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jconsole.html) and the `HotSpotDiagnosticMXBean` interface description at `http://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html` 77 | 78 | - 使用 `jconsole` 选项通过 HotSpotDiagnosticMXBean 从运行时获得堆转储。 请参考: 79 | * [jconsole(1)](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jconsole.html) 80 | * [`HotSpotDiagnosticMXBean` 接口](http://docs.oracle.com/javase/8/docs/jre/api/management/extension/com/sun/management/HotSpotDiagnosticMXBean.html). 81 | 82 | - Heap dump is generated when an `OutOfMemoryError` is thrown by specifying the `-XX:+HeapDumpOnOutOfMemoryError` Java Virtual Machine (JVM) option. 83 | 84 | - 如果在JVM启动时指定了 `-XX:+HeapDumpOnOutOfMemoryError` 选项, 则发生 **OutOfMemoryError** 时, 会自动生成堆转储。 85 | 86 | - Use the `hprof` command. See the HPROF: A Heap/CPU Profiling Tool at `http://docs.oracle.com/javase/8/docs/technotes/samples/hprof.html` 87 | 88 | - 使用 `hprof` 命令。 请参考 性能分析工具-HPROF简介, 89 | 90 | 91 | 92 | ### Options 93 | 94 | ### 选项参数 95 | 96 | - `-stack false|true` 97 | 98 | Turns off tracking object allocation call stack. If allocation site information is not available in the heap dump, then you have to set this flag to `false`. The default is `true`. 99 | 100 | 关闭对象分配调用栈跟踪(tracking object allocation call stack)。 如果在堆转储中分配位置信息不可用. 则必须将此标志设置为 false. 默认值为 `true`. 101 | 102 | - `-refs false|true` 103 | 104 | Turns off tracking of references to objects. Default is `true`. By default, back pointers, which are objects that point to a specified object such as referrers or incoming references, are calculated for all objects in the heap. 105 | 106 | 关闭对象引用跟踪(tracking of references to objects)。 默认值为 `true`. 默认情况下, 会统计整个堆内存中所有对象的反向指针, 即指向某个特定对象的对象, 如反向链接(referrers)或指向对象的引用(incoming references), 。 107 | 108 | - `-port ` 109 | 110 | Sets the port for the `jhat` HTTP server. Default is 7000. 111 | 112 | 设置 jhat HTTP server 的端口号. 默认值 `7000`. 113 | 114 | - `-exclude ` 115 | 116 | Specifies a file that lists data members that should be excluded from the reachable objects query. For example, if the file lists `java.lang.String.value`, then, then whenever the list of objects that are reachable from a specific object `o` are calculated, reference paths that involve `java.lang.String.value` field are not considered. 117 | 118 | 指定在可达对象查询时,需要排除的文件。 例如, 如果文件列出了 `java.lang.String.value`, 那么当从某个特定对象 `Object o` 计算可达的对象列表时, 涉及 `java.lang.String.value` 的引用路径都会被排除。 119 | 120 | - `-baseline ` 121 | 122 | Specifies a baseline heap dump. Objects in both heap dumps with the same object ID are marked as not being new. Other objects are marked as new. This is useful for comparing two different heap dumps. 123 | 124 | 指定一个基准堆转储(baseline heap dump)。 在两个 heap dumps 中有相同 object ID 的对象不会被标记为新对象. 其他对象被标记为新对象. 在比较两个堆转储文件时使用. 125 | 126 | - `-debug ` 127 | 128 | Sets the debug level for this tool. A level of 0 means no debug output. Set higher values for more verbose modes. 129 | 130 | 设置 debug 级别。 level `0` 表示不输出调试信息。 值越大则输出更详细的 debug 信息. 131 | 132 | - `-version` 133 | 134 | Reports the release number and exits 135 | 136 | JVM工具通用选项; 启动后显示版本信息并退出 137 | 138 | - `-h` 139 | 140 | Displays a help message and exits. 141 | 142 | JVM工具通用选项; 启动后显示帮助信息并退出. 等同于 `-help` 143 | 144 | - `-help` 145 | 146 | Displays a help message and exits. 147 | 148 | JVM工具通用选项; 启动后显示帮助信息并退出. 等同于 `-h` 149 | 150 | - `-J` 151 | 152 | Passes `flag` to the Java Virtual Machine on which the `jhat` command is running. For example, `-J-Xmx512m` to use a maximum heap size of 512 MB. 153 | 154 | 指定传给底层JVM的参数。 因为 jhat 命令实际上是通过JVM来执行的, 通过 `-J` 可以给底层JVM传入启动参数``. 例如, `-J-Xmx512m` 则指定运行底层JVM可以使用的堆内存最大值为 512 MB. 如果需要传入多个JVM启动参数,则传入多个 `-J`. 155 | 156 | 157 | 158 | 159 | 160 | ### See Also 161 | 162 | ### 另请参阅: 163 | 164 | - [`jmap`](./jmap.md) 165 | - [`jconsole`(1)](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jconsole.html#CACDDJCH) 166 | - 性能分析工具-HPROF简介, 167 | 168 | 原文链接: 169 | 170 | 171 | -------------------------------------------------------------------------------- /15_Troubleshooting/jinfo.md: -------------------------------------------------------------------------------- 1 | ## jinfo 2 | 3 | Generates configuration information. This command is experimental and unsupported. 4 | 5 | 6 | 7 | ### Synopsis 8 | 9 | ``` 10 | jinfo [option] 11 | 12 | jinfo [option] 13 | 14 | jinfo [option] [servier-id] 15 | ``` 16 | - `option` 17 | 18 | The command-line options. See Options. 19 | 20 | - `pid` 21 | 22 | The process ID for which the configuration information is to be printed. The process must be a Java process. To get a list of Java processes running on a machine, use the [`jps`](../13_Monitor_JVM/1301_jps.md) command. 23 | 24 | - `executable` 25 | 26 | The Java executable from which the core dump was produced. 27 | 28 | - `core` 29 | 30 | The core file for which the configuration information is to be printed. 31 | 32 | - `` 33 | 34 | The remote debug server `hostname` or `IP` address. See [`jsadebugd`(1)](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jsadebugd.html#BHBHHJCA). 35 | 36 | - `server-id` 37 | 38 | An optional unique ID to use when multiple debug servers are running on the same remote host. 39 | 40 | ## Description 41 | 42 | The `jinfo` command prints Java configuration information for a specified Java process or core file or a remote debug server. The configuration information includes Java system properties and Java Virtual Machine (JVM) command-line flags. If the specified process is running on a 64-bit JVM, then you might need to specify the `-J-d64` option, for example: `jinfo` `-J-d64 -sysprops pid`. 43 | 44 | This utility is unsupported and might not be available in future releases of the JDK. In Windows Systems where `dbgeng.dll` is not present, Debugging Tools For Windows must be installed to have these tools working. The `PATH` environment variable should contain the location of the jvm.dll that is used by the target process or the location from which the crash dump file was produced. For example, `set PATH=%JDK_HOME%\jre\bin\client;%PATH%` . 45 | 46 | 47 | ### Options 48 | 49 | - `no-option` 50 | 51 | Prints both command-line flags and system property name-value pairs. 52 | 53 | - `-flag name` 54 | 55 | Prints the name and value of the specified command-line flag. 56 | 57 | - `-flag [+|-]name` 58 | 59 | enables or disables the specified Boolean command-line flag. 60 | 61 | - `-flag name=value` 62 | 63 | Sets the specified command-line flag to the specified value. 64 | 65 | - `-flags` 66 | 67 | Prints command-line flags passed to the JVM. 68 | 69 | - `-sysprops` 70 | 71 | Prints Java system properties as name-value pairs. 72 | 73 | - `-h` 74 | 75 | Prints a help message. 76 | 77 | - `-help` 78 | 79 | Prints a help message. 80 | 81 | 82 | 83 | 84 | ### See Also 85 | 86 | 87 | - [jps](../13_Monitor_JVM/1301_jps.md) 88 | - [jsadebugd](./jsadebugd.md) 89 | 90 | -------------------------------------------------------------------------------- /15_Troubleshooting/jmap.md: -------------------------------------------------------------------------------- 1 | ## jmap 2 | 3 | Prints shared object memory maps or heap memory details for a process, core file, or remote debug server. This command is experimental and unsupported. 4 | 5 | ### Synopsis 6 | 7 | jmap [ options ] pid 8 | 9 | jmap [ options ] executable core 10 | 11 | jmap [ options ] [ pid ] server-id@ ] remote-hostname-or-IP 12 | 13 | 14 | #### options 15 | 16 | The command-line options. See Options. 17 | 18 | #### pid 19 | 20 | The process ID for which the memory map is to be printed. The process must be a Java process. To get a list of Java processes running on a machine, use the jps(1) command. 21 | 22 | #### executable 23 | 24 | The Java executable from which the core dump was produced. 25 | 26 | #### core 27 | 28 | The core file for which the memory map is to be printed. 29 | 30 | #### remote-hostname-or-IP 31 | 32 | The remote debug server hostname or IP address. See jsadebugd(1). 33 | 34 | #### server-id 35 | 36 | An optional unique ID to use when multiple debug servers are running on the same remote host. 37 | 38 | ### Description 39 | 40 | The jmap command prints shared object memory maps or heap memory details of a specified process, core file, or remote debug server. If the specified process is running on a 64-bit Java Virtual Machine (JVM), then you might need to specify the -J-d64 option, for example: jmap -J-d64 -heap pid. 41 | 42 | > Note: This utility is unsupported and might not be available in future releases of the JDK. On Windows Systems where the dbgeng.dll file is not present, Debugging Tools For Windows must be installed to make these tools work. The PATH environment variable should contain the location of the jvm.dll file that is used by the target process or the location from which the crash dump file was produced, for example: set PATH=%JDK_HOME%\jre\bin\client;%PATH%. 43 | 44 | ### Options 45 | 46 | #### `` 47 | 48 | When no option is used, the jmap command prints shared object mappings. For each shared object loaded in the target JVM, the start address, size of the mapping, and the full path of the shared object file are printed. This behavior is similar to the Oracle Solaris pmap utility. 49 | 50 | #### -dump:[live,] format=b, file=filename 51 | 52 | Dumps the Java heap in hprof binary format to filename. The live suboption is optional, but when specified, only the active objects in the heap are dumped. To browse the heap dump, you can use the jhat(1) command to read the generated file. 53 | 54 | 将Java堆以二进制格式hprof转储到文件中。`live` 子选项是可选的,如果指定该选项, 则只会导出堆内存中的存活对象。要查看堆转储, 可以使用 `jhat` 命令来读取生成的文件。 55 | 56 | > 示例: `jmap -dump:live,format=b,file=/usr/local/6578_160613.hprof 6578` 57 | 58 | 59 | #### -finalizerinfo 60 | 61 | Prints information about objects that are awaiting finalization. 62 | 63 | 输出等待终结(awaiting finalization)的对象信息。 64 | 65 | 66 | > 示例: `jmap -finalizerinfo 6578` 67 | 68 | #### -heap 69 | 70 | Prints a heap summary of the garbage collection used, the head configuration, and generation-wise heap usage. In addition, the number and size of interned Strings are printed. 71 | 72 | 输出垃圾收集使用的堆内存汇总信息,包括 head 配置和各个分代(generation-wise)的堆使用情况。此外,也会输出内部化字符串(interned Strings)的数量和大小。 73 | (建议: 不要在生产环境执行 jmap -heap) 74 | 75 | > 示例: `jmap -heap 6578` 76 | 77 | 78 | #### -histo[:live] 79 | 80 | Prints a histogram of the heap. For each Java class, the number of objects, memory size in bytes, and the fully qualified class names are printed. The JVM internal class names are printed with an asterisk (*) prefix. If the live suboption is specified, then only active objects are counted. 81 | 82 | 83 | 输出堆内存的直方图统计信息。会输出每个Java类的实例数量,占用内存大小(字节),以及完全限定类名。JVM内部类名会带有一个星号(*)前缀。如果指定 `live` 子选项, 则只会统计存活对象(JVM会先触发gc,再进行统计)。 84 | 85 | 86 | > 示例: `jmap -histo:live 6578 > histo_6578.log` 87 | 88 | 89 | 90 | #### -clstats 91 | 92 | Prints class loader wise statistics of Java heap. For each class loader, its name, how active it is, address, parent class loader, and the number and size of classes it has loaded are printed. 93 | 94 | 输出以类加载器为维度识别的Java堆统计信息。对每个类加载器(class loader), 名字,活跃状态,地址, 父加载器, 加载类的数量和大小都会打印出来。 95 | 96 | > JDK7 不提供支持. 97 | 98 | > 示例: `jmap -clstats 6578` 99 | 100 | #### -F 101 | 102 | Force. Use this option with the jmap -dump or jmap -histo option when the pid does not respond. The live suboption is not supported in this mode. 103 | 104 | 强制模式。 在使用 `jmap -dump` or `jmap -histo` 选项时,如果 pid 不响应,则可以使用此参数。 注意: `live`子选项不支持此模式。 105 | 106 | #### -h 107 | 108 | 输出帮助信息(help message). 109 | 110 | #### -help 111 | 112 | 输出帮助信息(help message). 113 | 114 | #### -J 115 | 116 | 117 | 通过此选项,指定用于 **运行jmap的Java虚拟机** 的参数。 118 | 119 | > 示例: `jmap -J-Xmx128m 6578` 120 | 121 | 122 | ### 另请参见 123 | 124 | - [jhat](./jhat.md) 125 | 126 | - [jps](../13_Monitor_JVM/1301_jps.md) 127 | 128 | - [jsadebugd](./jsadebugd.md) 129 | 130 | 原文链接: [http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jmap.html](http://docs.oracle.com/javase/8/docs/technotes/tools/windows/jmap.html) 131 | 132 | 133 | -------------------------------------------------------------------------------- /15_Troubleshooting/jsadebugd.md: -------------------------------------------------------------------------------- 1 | ## jsadebugd 2 | 3 | Attaches to a Java process or core file and acts as a debug server. This command is experimental and unsupported. 4 | 5 | 6 | ### Synopsis 7 | 8 | ``` 9 | jsadebugd pid [server-id] 10 | 11 | jsadebugd executable core [server-id] 12 | ``` 13 | 14 | - `pid` 15 | 16 | The process ID of the process to which the debug server attaches. The process must be a Java process. To get a list of Java processes running on a machine, use the [`jps`(1)](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/jps.html) command. At most one instance of the debug server can be attached to a single process. 17 | 18 | - `executable` 19 | 20 | The Java executable from which the core dump was produced. 21 | 22 | - `core` 23 | 24 | The core file to which the debug server should attach. 25 | 26 | - `server-id` 27 | 28 | An optional unique ID that is needed when multiple debug servers are started on the same machine. This ID must be used by remote clients to identify the particular debug server to which to attach. Within a single machine, this ID must be unique. 29 | 30 | ### Description 31 | 32 | The `jsadebugd` command attaches to a Java process or core file and acts as a debug server. Remote clients such as `jstack`, `jmap`, and `jinfo` can attach to the server through Java Remote Method Invocation (RMI). Before you start the `jsadebugd` command, start the RMI registry with the `rmiregistry` command as follows where `$JAVA_HOME` is the JDK installation directory: 33 | 34 | ``` 35 | rmiregistry -J-Xbootclasspath/p:$JAVA_HOME/lib/sajdi.jar 36 | ``` 37 | 38 | If the RMI registry was not started, then the `jsadebugd` command starts an RMI registry in a standard (1099) port internally. The debug server can be stopped by sending a `SIGINT` to it. To send a SIGINT press **Ctrl+C**. 39 | 40 | **Note:** This utility is unsupported and may or may not be available in future releases of the JDK. In Windows Systems where `dbgeng.dll` is not present, Debugging Tools For Windows must be installed to have these tools working. The `PATH` environment variable should contain the location of jvm.dll used by the target process or the location from which the crash dump file was produced. For example, `set PATH=%JDK_HOME%\jre\bin\client;%PATH%`. 41 | 42 | 43 | 44 | 45 | 46 | ### See Also 47 | 48 | 49 | - [`jinfo`](./jinfo.md) 50 | - [`jmap`](./jmap.md) 51 | - [jps](../13_Monitor_JVM/1301_jps.md) 52 | - [`jstack`](./jstack.md) 53 | - [`rmiregistry`](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/rmiregistry.html) 54 | 55 | -------------------------------------------------------------------------------- /15_Troubleshooting/jstack.md: -------------------------------------------------------------------------------- 1 | ## jstack 2 | 3 | Prints Java thread stack traces for a Java process, core file, or remote debug server. This command is experimental and unsupported. 4 | 5 | 打印Java线程栈跟踪信息, 目标可以是 Java进程, core文件,或支持远程调试的服务器。此命令是实验性质的,官方不提供服务支持。 6 | 7 | 8 | ### Synopsis 9 | 10 | ### 简介 11 | 12 | ``` 13 | jstack [ *options* ] pid 14 | 15 | jstack [ *options* ] executable core 16 | 17 | jstack [ *options* ] [ *server-id*@ ] remote-hostname-or-IP 18 | ``` 19 | 20 | #### options 21 | 22 | 23 | The command-line options. See Options. 24 | 25 | jstack支持的命令行选项。请参考下面的 [选项] 部分。 26 | 27 | 28 | #### pid 29 | 30 | The process ID for which the stack trace is printed. The process must be a Java process. To get a list of Java processes running on a machine, use the jps(1) command. 31 | 32 | 进程ID, 要打印线程栈跟踪信息的进程ID,必须是一个Java进程。要获得某台机器上的 Java进程列表, 请使用 `jps` 命令。 33 | 34 | 35 | #### executable 36 | 37 | The Java executable from which the core dump was produced. 38 | 39 | Java可执行的核心转储。 40 | 41 | 42 | #### core 43 | 44 | The core file for which the stack trace is to be printed. 45 | 46 | 核心文件, 要显示堆栈跟踪信息的核心文件。 47 | 48 | 49 | #### remote-hostname-or-IP 50 | 51 | The remote debug server hostname or IP address. See jsadebugd(1). 52 | 53 | 支持远程调试的服务器的主机名或IP地址。详情请参考 `jsadebugd` 命令。 54 | 55 | 56 | #### server-id 57 | 58 | An optional unique ID to use when multiple debug servers are running on the same remote host. 59 | 60 | 可选参数, 如果远程主机上同时运行了多个支持远程调试的服务器, 则需要指定唯一ID。 61 | 62 | 63 | ### Description 64 | 65 | ### 描述 66 | 67 | 68 | The jstack command prints Java stack traces of Java threads for a specified Java process, core file, or remote debug server. For each Java frame, the full class name, method name, byte code index (BCI), and line number, when available, are printed. With the -m option, the jstack command prints both Java and native frames of all threads with the program counter (PC). For each native frame, the closest native symbol to PC, when available, is printed. C++ mangled names are not demangled. To demangle C++ names, the output of this command can be piped to c++filt. When the specified process is running on a 64-bit Java Virtual Machine, you might need to specify the -J-d64 option, for example: jstack -J-d64 -m pid. 69 | 70 | jstack命令打印Java Java线程的堆栈跟踪指定的Java进程,核心文件,或远程调试服务器.对于每一个Java框架,完整的类名,方法名,字节码指数(BCI),和行号,当可用时,打印出来.使用- m选项,jstack命令打印所有线程的Java和本地框架程序计数器(PC).对于每一个本地框架,最接近电脑,本地符号可用时,打印。c++不是demangled支离破碎的名字。demangle c++名称,该命令的输出可以输送到c++ filt.当指定的进程上运行一个64位的Java虚拟机,您可能需要指定-J-d64选项,例如:jstack -J-d64 - m pid。 71 | 72 | 73 | > **Note**: This utility is unsupported and might not be available in future release of the JDK. In Windows Systems where the dbgeng.dll file is not present, Debugging Tools For Windows must be installed so these tools work. The PATH environment variable needs to contain the location of the jvm.dll that is used by the target process, or the location from which the crash dump file was produced. For example: 74 | 75 | > **注意**:这个工具是不支持的,可能不会在未来版本的JDK。dbgeng在Windows系统.Windows dll文件不存在,调试工具必须安装这些工具的工作。PATH环境变量需要包含jvm的位置.使用dll,目标过程,或崩溃转储文件的位置。例如: 76 | 77 | 78 | 79 | set PATH=\jre\bin\client;%PATH% 80 | 81 | ### Options 82 | 83 | ### 选项 84 | 85 | 86 | #### -F 87 | 88 | Force a stack dump when jstack [-l] pid does not respond. 89 | 90 | 如果 `jstack [-l] pid` 不响应, 则强制进行 stack 转储。 91 | 92 | 93 | #### -l 94 | 95 | Long listing. Prints additional information about locks such as a list of owned java.util.concurrent ownable synchronizers. See the AbstractOwnableSynchronizer class description at 96 | http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/AbstractOwnableSynchronizer.html 97 | 98 | 打印详细信息(Long listing)。打印关于锁的额外信息, 如持有 `java.util.concurrent` 的锁定者。详情请参考 `AbstractOwnableSynchronizer` 类的描述信息: 99 | [http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/AbstractOwnableSynchronizer.html](http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/locks/AbstractOwnableSynchronizer.html) 100 | 101 | 102 | #### -m 103 | 104 | Prints a mixed mode stack trace that has both Java and native C/C++ frames. 105 | 106 | 打印混合模式(mixed mode)的堆栈跟踪, 包括Java和C/C++框架。 107 | 108 | 109 | #### -h 110 | 111 | Prints a help message. 112 | 113 | 打印帮助(help)信息。 114 | 115 | 116 | #### -help 117 | 118 | Prints a help message. 119 | 120 | 打印帮助(help)信息。 121 | 122 | 123 | ### Known Bugs 124 | 125 | ### 已知的Bug 126 | 127 | 128 | In mixed mode stack trace, the -m option does not work with the remote debug server. 129 | 130 | 在混合模式下, `-m` 选项不支持远程调试服务器。 131 | 132 | 133 | ### See Also 134 | 135 | ### 另请参阅 136 | 137 | 138 | - [jps](../13_Monitor_JVM/1301_jps.md) 139 | 140 | - [jsadebugd](./jsadebugd.md) 141 | 142 | 原文链接: 143 | 144 | -------------------------------------------------------------------------------- /16_Scripting/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cncounter/java-tools-cn/a42a92f170598b3476c7343de0425bf20ab372e7/16_Scripting/README.md -------------------------------------------------------------------------------- /Copyright_Information.md: -------------------------------------------------------------------------------- 1 | #Title and Copyright Information 2 | 3 | Java Platform, Standard Edition 4 | Tools Reference 5 | 6 | Release 8 for Oracle JDK on Windows 7 | 8 | E38210-04 9 | 10 | March 2015 11 | 12 | This document contains reference information for the tools that are installed with Java Development Kit (JDK). 13 | 14 | Java Platform, Standard Edition Tools Reference Release 8 for Oracle JDK on Windows 15 | 16 | E38210-04 17 | 18 | Copyright 1993, 2015,Oracle and/or its affiliates. All rights reserved. 19 | 20 | This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. 21 | 22 | The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. 23 | 24 | If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: 25 | 26 | U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, shall be subject to license terms and license restrictions applicable to the programs. No other rights are granted to the U.S. Government. 27 | 28 | This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications. 29 | 30 | Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. 31 | 32 | Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group. 33 | 34 | This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle. -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JDK 辅助工具参考文档中文版 2 | 3 | Java Platform, Standard Edition Tools Reference 4 | 5 | 英文版地址: 6 | 7 | Unix英文版: 8 | 9 | Java8的手册目录: 10 | 11 | 站点地址: 12 | 13 | 14 | 原作者: 15 | 16 | 17 | 本翻译文档由CNCounter中文翻译组于2015年12月21日开始翻译,版权由原文版权所有者和翻译组共同所有。参与翻译请在wiki留言: 。 18 | 19 | 翻译组成员列表如下(排名不分先后): 20 | 21 | * 铁锚([http://blog.csdn.net/renfufei](http://blog.csdn.net/renfufei)) 22 | * jefferchang([https://github.com/jefferchang](https://github.com/jefferchang)) 23 | * yuanmomo([https://github.com/yuanmomo](https://github.com/yuanmomo)) 24 | * zhaiwei([https://github.com/zhaiweij](https://github.com/zhaiweij)) 25 | 26 | 完成百分比:0/17 ~ 0% 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 |
章节页数翻译者状态计划完成时间
00 -
01 - 铁锚 doing 2016-05-10
02 - 成都-理工男 doing 2016-05-24
03 - 铁锚 doing 2016-05-10
04 -
05 - 翟伟 doing 2017-05-24
06 - 翟伟 doing 2017-05-24
07 -
08 -
09 -
10 -
11 -
12 -
13 -
14 -
15 -
16 -
176 | 177 | --------------------------------------------------------------------------------