[Reference]javadoc的使用实例

news/2024/7/4 23:08:11 标签: javadoc, reference, documentation, path, button, c
cle class="baidu_pl">
cle_content" class="article_content clearfix">
content_views" class="htmledit_views">

文献出处: http://java.sun.com/j2se/1.5.0/docs/tooldocs/windows/class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc.html#examples

SIMPLE EXAMPLES

ckquote> You can run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc on entire packages or individual source files. Each package name has a corresponding directory name. In the following examples, the source files are located at <code>C:/home/src/java/awt/*javacode>. The destination directory is <code>C:/home/htmlcode>.

Documenting One or More Packages

To document a package, the source files ( <code>*.javacode>) for that package must be located in a directory having the same name as the package. If a package name is made up of several identifiers (separated by dots, such as <code>java.awt.colorcode>), each subsequent identifier must correspond to a deeper subdirectory (such as <code>java/awt/colorcode>). You may split the source files for a single package among two such directory trees located at different places, as long as <code>-sourceclass="tags" href="/tags/PATH.html" title=path>pathcode> points to them both -- for example <code>src1/java/awt/colorcode> and <code>src2/java/awt/colorcode>.

You can run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc either by changing directories (with <code>cdcode>) or by using <code>-sourceclass="tags" href="/tags/PATH.html" title=path>pathcode> option. The examples below illustrate both alternatives.

  • Case 1 - Run recursively starting from one or more packages - This example uses -sourceclass="tags" href="/tags/PATH.html" title=path>path so class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc can be run from any directory and -subpackages (a new 1.4 option) for recursion. It traverses the subpackages of the <code>javacode> directory excluding packages rooted at <code>java.netcode> and <code>java.langcode>. Notice this excludes <code>java.lang.refcode>, a subpackage of <code>java.langcode>).
      % class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d /home/html -sourceclass="tags" href="/tags/PATH.html" title=path>path /home/src -subpackages java -exclude java.net:java.lang
    

    To also traverse down other package trees, append their names to the <code>-subpackagescode> argument, such as <code>java:javax:org.xml.saxcode>.

     

  • Case 2 - Run on explicit packages after changing to the "root" source directory - Change to the parent directory of the fully-qualified package. Then run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc, supplying names of one or more packages you want to document:
      C:> cd C:/home/src/
      C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d C:/home/html java.awt java.awt.event
    
  • Case 3 - Run from any directory on explicit packages in a single directory tree - In this case, it doesn't matter what the current directory is. Run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc supplying <code>-sourceclass="tags" href="/tags/PATH.html" title=path>pathcode> with the parent directory of the top-level package, and supplying names of one or more packages you want to document:
      C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d C:/home/html -sourceclass="tags" href="/tags/PATH.html" title=path>path C:/home/src java.awt java.awt.event
    
  • Case 4 - Run from any directory on explicit packages in multiple directory trees - This is the same as case 3, but for packages in separate directory trees. Run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc supplying <code>-sourceclass="tags" href="/tags/PATH.html" title=path>pathcode> with the class="tags" href="/tags/PATH.html" title=path>path to each tree's root (colon-separated) and supply names of one or more packages you want to document. All source files for a given package do not need to be located under a single root directory -- they just need to be found somewhere along the sourceclass="tags" href="/tags/PATH.html" title=path>path.
      C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d C:/home/html -sourceclass="tags" href="/tags/PATH.html" title=path>path C:/home/src1;C:/home/src2 java.awt java.awt.event
    
Result: All cases generate HTML-formatted class="tags" href="/tags/DOCUMENTATION.html" title=documentation>documentation for the public and protected classes and interfaces in packages <code>java.awtcode> and <code>java.awt.eventcode> and save the HTML files in the specified destination directory ( <code>C:/home/htmlcode>). Because two or more packages are being generated, the document has three HTML frames -- for the list of packages, the list of classes, and the main class pages.

Documenting One or More Classes

The second way to run the Javadoc tool is by passing in one or more source files ( <code>.javacode>). You can run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc either of the following two ways -- by changing directories (with <code>cdcode>) or by fully-specifying the class="tags" href="/tags/PATH.html" title=path>path to the <code>.javacode> files. Relative class="tags" href="/tags/PATH.html" title=path>paths are relative to the current directory. The <code>-sourceclass="tags" href="/tags/PATH.html" title=path>pathcode> option is ignored when passing in source files. You can use command line wildcards, such as asterisk (*), to specify groups of classes.

  • Case 1 - Changing to the source directory - Change to the directory holding the <code>.javacode> files. Then run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc, supplying names of one or more source files you want to document.
      C:> cd C:/home/src/java/awt
      C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d C:/home/html Button.java Canvas.java Graphics*.java
    
    This example generates HTML-formatted class="tags" href="/tags/DOCUMENTATION.html" title=documentation>documentation for the classes <code>Buttoncode>, <code>Canvascode> and classes beginning with <code>Graphicscode>. Because source files rather than package names were passed in as arguments to class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc, the document has two frames -- for the list of classes and the main page.

     

  • Case 2 - Changing to the package root directory - This is useful for documenting individual source files from different subpackages off the same root. Change to the package root directory, and supply the source files with class="tags" href="/tags/PATH.html" title=path>paths from the root.
      C:> cd C:/home/src
      C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d /home/html java/awt/Button.java java/applet/Applet.java
    
    This example generates HTML-formatted class="tags" href="/tags/DOCUMENTATION.html" title=documentation>documentation for the classes <code>Buttoncode> and <code>Appletcode>.

     

  • Case 3 - From any directory - In this case, it doesn't matter what the current directory is. Run class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc supplying the absolute class="tags" href="/tags/PATH.html" title=path>path (or class="tags" href="/tags/PATH.html" title=path>path relative to the current directory) to the <code>.javacode> files you want to document.
      C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d C:/home/html C:/home/src/java/awt/Button.java C:/home/src/java/awt/Graphics*.java
    
    This example generates HTML-formatted class="tags" href="/tags/DOCUMENTATION.html" title=documentation>documentation for the class <code>Buttoncode> and classes beginning with <code>Graphicscode>.

Documenting Both Packages and Classes

You can document entire packages and individual classes at the same time. Here's an example that mixes two of the previous examples. You can use <code>-sourceclass="tags" href="/tags/PATH.html" title=path>pathcode> for the class="tags" href="/tags/PATH.html" title=path>path to the packages but not for the class="tags" href="/tags/PATH.html" title=path>path to the individual classes.
  C:> class="tags" href="/tags/JAVADOC.html" title=javadoc>javadoc -d C:/home/html -sourceclass="tags" href="/tags/PATH.html" title=path>path C:/home/src java.awt C:/home/src/java/applet/Applet.java
This example generates HTML-formatted class="tags" href="/tags/DOCUMENTATION.html" title=documentation>documentation for the package <code>java.awtcode> and class <code>Appletcode>. (The Javadoc tool determines the package name for <code>Appletcode> from the package declaration, if any, in the <code>Applet.javacode> source file.)

ckquote>
cle>

http://www.niftyadmin.cn/n/1277817.html

相关文章

Springboot项目打包成war包部署到tomcat上启动,使用外部自定义的配置文件

思路&#xff1a; 通过实现 EnvironmentPostProcessor 在程序启动加载程序环境的时候加载自定义的属性文件 参考地址&#xff1a; https://blog.csdn.net/yangyun901222/article/details/82287383

XDOJ1245 - 蛋疼的Plato

Description 快过生日了&#xff0c;Plato收到了很多礼物。每个礼物都有一个金额&#xff0c;无聊的Plato想知道这些礼物中第K大的价格是多少。 Input 多组数据 每组数据第一行有两个数N&#xff08;0<N<500000&#xff09;和K&#xff08;0<K<500&#xff09;&…

自定义shiro中RedisSessionDAO的keyPrefix

shiro中原始的RedisSessionDAO如下&#xff0c;keyPrefix为shiro_redis_session:&#xff0c;某些情况下需要自定义这个值 // // Source code recreated from a .class file by IntelliJ IDEA // (powered by Fernflower decompiler) //package org.crazycake.shiro;import ja…

XDOJ1260 - 递推1

Description 在所有的N位数中&#xff0c;有多少个数中有偶数个数字3&#xff1f; Input 多组数据&#xff0c;每行一个数N&#xff08;N<1000&#xff09; Output 每行输出一个数&#xff0c;答案mod12345 Sample Input 2 Sample Output 73 解题思路&#xff1a; …

Log4j的进阶使用-自定义Logger类 + 自定义打印文件位置

1.log4j配置文件信息 #自定义日志打印类的配置文件信息 log4j.logger.customerLogger INFO,customerLogger #文件大小到达指定尺寸的时候产生一个新的文件 log4j.appender.customerLogger org.apache.log4j.RollingFileAppender #指定输出目录 log4j.appender.customerLog…

XDOJ1261 - 递推2

Description 用1 x 1和2 x 2的磁砖不重叠地铺满N x 3的地板&#xff0c;共有多少种方案&#xff1f; Input 多组数据&#xff0c;每行一个数N&#xff08;N<1000&#xff09; Output 每行输出一个数&#xff0c;答案mod12345 Sample Input 2 Sample Output 3 解题…

解决java.lang.ClassCastException class java.lang.Integer cannot be cast to class java.lang.Long异常

下面代码段&#xff0c;用jdbcTemplate.queryForMap查询数据库表的ID时&#xff0c;虽然编译通过没有报错&#xff0c;但会有问题&#xff1a; try {Map<String,Object> userPo jdbcTemplate.queryForMap("select * from auth_user where username" usernam…

QoS令牌桶工作原理

QoS的一个重要作用就是对port流量进行监管&#xff0c;也就是限制port流量。但QoS是怎样做到这点的呢&#xff1f;那就是QoS的令牌桶机制了。以下是在笔者刚刚出版的《Cisco/H3C交换机高级配置与管理技术手冊》一书中&#xff0c;经过笔者充分理解后的全面诠释&#xff0c;大家…