生成单个文件的javadoc

89页 Excersice15

Add comment documentation to the Application.java. Extract this comment documentation into an HTML file using Javadoc and view it with your Web browser.

javadoc -d doc Application.java

此时报错:Application.java:2: 错误: 编码GBK的不可映射字符。
这个错误是由于文件编码与Javadoc工具默认编码不匹配导致的。以下是解决方案:

# 在生成命令中显式指定UTF-8编码
javadoc -encoding UTF-8 -d doc Application.java

生成javadoc:

# Windows
start doc\index.html

# macOS
open doc/index.html

# Linux
xdg-open doc/index.html

关键点说明:

  • /** ... */ 是Javadoc的标准注释格式
  • -d doc 参数指定文档输出目录
  • 生成的文档包含类描述、方法说明和参数信息
  • 可以通过浏览器查看完整的API文档结构
posted @ 2025-04-28 09:06  尼兰  阅读(3)  评论(0)    收藏  举报