13

Let's say for example that I want to link java.lang.Double's equals method using a html tag:

@see <a href="http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Double.html#equals(java.lang.Object)">

This is ok, but I haven't understood how to link a non-standard class.
For example I am developing two classes, named AbstractVehicle and Vehicle.But there isn't the AbstractVehicle's javadoc documentation because it's documentation has still to be generated.
Then how do I link it's method or class reference? Consider this:

@see mypackage.AbstractVehilce

This doesn't put the class URL, I would know how to get the URL or it's reference before generating the documentation.
I hope that the question is clear, tell me otherwise.

Ramy Al Zuhouri
  • 21,580
  • 26
  • 105
  • 187

3 Answers3

13

To create a link to a specific class you can use the {@link mypackage.AbstractVehicle} tag. Likewise, you can use {@link mypackage.AbstractVehicle#someMethod} to create a link to someMethod() in the AbstractVehicle class.

More javadoc recommendations can be found at Oracle's javadoc - The Java API Documentation Generator page.

matsev
  • 32,104
  • 16
  • 121
  • 156
  • Does the full package name need to be specified if the JavaDoc is added to a different class in the same package? – Stevoisiak Apr 08 '17 at 22:06
3

The manpage for javadoc explains the -link and -linkoffline which control how links are generated for packages not passed to javadoc.

   -link extdocURL
          Creates  links to existing javadoc-generated documentation
          of external referenced classes.  It takes one argument.

          extdocURL is the absolute or relative URL of the directory
          containing  the  external  javadoc-generated documentation
          you want to link to. Examples are shown below.  The  pack-
          age-list  file must be found in this directory (otherwise,
          use -linkoffline). The  Javadoc  tool  reads  the  package
          names  from  the package-list file and then links to those
          packages at that URL. When the Javadoc tool  is  run,  the
          extdocURL  value  is  copied  literally  into the <A HREF>
          links that are created. Therefore, extdocURL must  be  the
          URL to the directory, not to a file.

          You  can use an absolute link for extdocURL to enable your
          docs to link to a document on any website, or  can  use  a
          relative link to link only to a relative location. If rel-
          ative, the value you pass in should be the  relative  path
          from the destination directory (specified with -d ) to the
          directory containing the packages being linked to.

          When specifying an absolute link you normally use an http:
          link.   However, if you want to link to a file system that
          has no web server, you can use a file: link - however,  do
          this only if everyone wanting to access the generated doc-
          umentation shares the same file system.

          You can specify multiple -link options in a given  javadoc
          run to link to multiple documents.

          Choosing between -linkoffline and -link - One or the other
          option is appropriate when linking to an API document that
          is external to the current javadoc run.

          Use  -link: when using a relative path to the external API
          document, or when using an absolute URL  to  the  external
          API  document,  if  you  shell does not allow a program to
          open a connection to that URL for reading.

          Use -linkoffline : when  using  an  absolute  URL  to  the
          external API document, if your shell does not allow a pro-
          gram to open a connection to that URL for  reading.   This
          can  occur  if  you are behind a firewall and the document
          you want to link to is on the other side.

          ...

and whereas -link requires you to be network connected when you generate the documentation so it can retrieve the package list over the network, -linkoffline does not but requires you to supply the package list yourself:

   -linkoffline extdocURL  packagelistLoc
          This option is a varition of -link; they both create links
          to javadoc-generated documentation for external referenced
          classes.  Use the -linkoffline option when  linking  to  a
          document  on  the  web  when  the  Javadoc  tool itself is
          "offline" - that is, it cannot access the document through
          a web connection.

          ...
Mike Samuel
  • 118,113
  • 30
  • 216
  • 245
2

What you can put after @see is described in the javadoc tool documentation. You should never put the URL of any external class or method documentation. Instead, you should put the class/method name, and use the -link option to let javadoc figure out the appropriate URL for you.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255