900

Something like:

/**
 * See {@linktourl http://google.com}
 */
Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
ripper234
  • 222,824
  • 274
  • 634
  • 905

4 Answers4

1419

This creates a "See Also" heading containing the link, i.e.:

/**
 * @see <a href="http://google.com">http://google.com</a>
 */

will render as:

See Also:
           http://google.com

whereas this:

/**
 * See <a href="http://google.com">http://google.com</a>
 */

will create an in-line link:

See http://google.com

Arsen Khachaturyan
  • 7,904
  • 4
  • 42
  • 42
aem999
  • 16,923
  • 4
  • 22
  • 12
  • 72
    If anyone is interested, since I just had to look it up: According to the [Javadoc spec](http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#orderoftags) the `@see` tag comes *after* the `@param`/`@return` tags and *before* the `@since`/`@serial`/`@deprecated` tags. – friederbluemle Oct 11 '13 at 05:18
  • 7
    Just in case, Intellij 13 does not seem to support this tag. It does support in-line links. Is the tag somehow deprecated? – Timo Jul 08 '14 at 15:08
  • When I use this with Maven, it warns about a missing final greater than symbol - anyone know why? – LB-- Aug 29 '14 at 17:54
  • 36
    I recommend `http://google.com.` The reason for adding target="_top" is because some of the generated javadoc html files make use of frames, and you probably want the navigation to affect the whole page rather than just the current frame. – Antony Nov 30 '16 at 21:31
  • 3
    If you get a warning like "warning - Tag \@see: missing final '>':", make sure you don't have two hyperlinks in the same \@see directive. Instead, use one link per \@see. – Travis Spencer Dec 27 '16 at 13:21
  • 17
    why is it so complicated to add a URL link to a javadoc ? who thought that HTML was a good idea... /facepalm – Someone Somewhere Jan 08 '18 at 15:26
  • 4
    If someone else is as lame as me and searching for the difference between the in-line version and the other for hours: Mind the '@' before 'See' ;) – István Őri Mar 09 '18 at 10:27
  • 3
    As a follow up to @Timo s remark: Intelij 2019.1 now does properly display a "see also" entry – Pieter De Bie Apr 03 '19 at 06:26
  • 3
    This is soooo.. 1997! – Thomas Beauvais Jul 07 '20 at 10:19
203

Taken from the javadoc spec

@see <a href="URL#value">label</a> : Adds a link as defined by URL#value. The URL#value is a relative or absolute URL. The Javadoc tool distinguishes this from other cases by looking for a less-than symbol (<) as the first character.

For example : @see <a href="http://www.google.com">Google</a>

matthias krull
  • 4,389
  • 3
  • 34
  • 54
Aaron
  • 5,931
  • 4
  • 27
  • 31
  • Weird; I swear I only added in the backticks; I don't know where the example went to... – Stobor Jul 04 '09 at 11:57
  • I think we had some kind of concurrent edit problem. I was putting them in also. – Aaron Jul 04 '09 at 12:00
  • Fair enough. You're missing the backticks in the first line of your blockquote, though.... – Stobor Jul 04 '09 at 12:06
  • 27
    @see is not needed. The javadocs can be formatted with html tags, so it's only necessary the "a" tag. – Gabriel Llamas Apr 23 '11 at 15:31
  • 6
    @GabrielLlamas True, but the original question implies this is how it's being used. It's useful to know that it specifically _does_ work in a see-also field, which is where a lot of people will want it. – Ionoclast Brigham Sep 01 '15 at 17:17
47

Javadocs don't offer any special tools for external links, so you should just use standard html:

See <a href="http://groversmill.com/">Grover's Mill</a> for a history of the
Martian invasion.

or

@see <a href="http://groversmill.com/">Grover's Mill</a> for a history of 
the Martian invasion.

Don't use {@link ...} or {@linkplain ...} because these are for links to the javadocs of other classes and methods.

Orlando DFree
  • 601
  • 5
  • 5
3

Hard to find a clear answer from the Oracle site. The following is from javax.ws.rs.core.HttpHeaders.java:

/**
 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.1">HTTP/1.1 documentation</a>}.
 */
public static final String ACCEPT = "Accept";

/**
 * See {@link <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.2">HTTP/1.1 documentation</a>}.
 */
public static final String ACCEPT_CHARSET = "Accept-Charset";
Sergej
  • 1,082
  • 11
  • 27
Qiang Li
  • 1,099
  • 11
  • 8
  • 2
    What is the significance of wrapping the `` html tag with the `{@link ...}`? – Patrick M Apr 14 '15 at 18:58
  • 4
    This is probably a mistake because [the javadoc documentation](http://docs.oracle.com/javase/6/docs/technotes/tools/windows/javadoc.html#@link) does not mention this form, in it does not make a difference from a raw ``. – Didier L May 29 '15 at 09:02
  • 9
    The {@link xxx} here isn't right. {@link xxx} is for linking to other classes and methods in your source code. It's unnecessary here. The rest of it is fine. – MiguelMunoz Sep 02 '15 at 00:16
  • 6
    This construct is not allowed by Java 8 standards (doclint on). – Stepan Vavra Oct 09 '15 at 14:12
  • 3
    This is plain wrong. The correct usage as per [reference](http://docs.oracle.com/javase/7/docs/technotes/tools/windows/javadoc.html#link) and [documentation](http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html#{@link}) is `{@link package.class#member label}` – Dinei Jun 23 '17 at 15:44
  • 2
    Tip: hey you could earn the `Disciplined` badge by deleting this post (which seems to have been voted as less helpful than the others) – Luke Usherwood Feb 26 '19 at 13:40
  • 2
    @LukeUsherwood The problem is that SO scoring algorithm gives you more positive points for an upvote than negative points for a downvote. Thus if you have 10 upvotes and 10 downvotes, and you are missing the self-discipline, you are not motivated to delete your (apparently wrong) answer :( I tried several times to flag such questions but in vain, the moderators answered me that they do not delete answers on the basis the they (= the answers) are incorrect. – Honza Zidek Nov 11 '20 at 11:40