Java 9 改进 Javadoc

Java 9 新特性 Java 9 新特性

javadoc 工具可以生成 Java 文档, Java 9 的 javadoc 的输出现在符合兼容 HTML5 标准。

Java 9 之前的旧版本文档

考虑以下文件代码 C:/JAVA/Tester.java:

实例

/** * @author MahKumar * @version 0.1 */ public class Tester { /** * Default method to be run to print * <p>Hello world</p> * @param args command line arguments */ public static void main(String []args) { System.out.println("Hello World"); } }

使用 jdk 7 的 javadoc 生成文档:

C:JAVA>javadoc -d C:/JAVA Tester.java
Loading source file tester.java...
Constructing Javadoc information...
Standard Doclet version 1.7.0_21
Building tree for all the packages and classes...
Generating C:JAVATester.html...
Generating C:JAVApackage-frame.html...
Generating C:JAVApackage-summary.html...
Generating C:JAVApackage-tree.html...
Generating C:JAVAconstant-values.html...
Building index for all the packages and classes...
Generating C:JAVAoverview-tree.html...
Generating C:JAVAindex-all.html...
Generating C:JAVAdeprecated-list.html...
Building index for all classes...
Generating C:JAVAallclasses-frame.html...
Generating C:JAVAallclasses-noframe.html...
Generating C:JAVAindex.html...
Generating C:JAVAhelp-doc.html...

执行以上命令会再 C:/JAVA 命令下生成文档页面,如下图所示:

Java 9 生成的文档兼容 HTML5 标准

使用 jdk 9 javadoc 命令中的 -html5 参数可以让生成的文档支持 HTML5 标准:

C:JAVA> javadoc -d C:/JAVA -html5 Tester.java
Loading source file Tester.java...
Constructing Javadoc information...
Standard Doclet version 9.0.1
Building tree for all the packages and classes...
Generating C:JAVATester.html...
Generating C:JAVApackage-frame.html...
Generating C:JAVApackage-summary.html...
Generating C:JAVApackage-tree.html...
Generating C:JAVAconstant-values.html...
Building index for all the packages and classes...
Generating C:JAVAoverview-tree.html...
Generating C:JAVAindex-all.html...
Generating C:JAVAdeprecated-list.html...
Building index for all classes...
Generating C:JAVAallclasses-frame.html...
Generating C:JAVAallclasses-frame.html...
Generating C:JAVAallclasses-noframe.html...
Generating C:JAVAallclasses-noframe.html...
Generating C:JAVAindex.html...
Generating C:JAVAhelp-doc.html...

执行以上命令会再 C:/JAVA 命令下生成文档页面,如下图所示:

Java 9 新特性 Java 9 新特性

其他扩展