I did my seach but couldn't find the right answer... How can I use link to a resource text file in Javadoc. {@link easywords.txt}
doesn't work. <a href="D:\NetBeans\HMan\easy.txt">Easy words</a>
doesn't work neither.
Asked
Active
Viewed 9,670 times
1 Answers
5
Try <a href="file:///D:/NetBeans/HMan/easy.txt">Easy words</a>
instead.
A Link should be a URL.
The browser may think D
would be protocol to handle requests.
For literature: http://en.wikipedia.org/wiki/File_URI_scheme

Grim
- 1,938
- 10
- 56
- 123
-
9A link to an absolute path in code? This would likely only work on the authors machine. – Novaterata May 04 '17 at 01:48
-
@Novaterata I think so. It also should not be a relative path because you never know what the base-path of the relative. It even should not be a path because the OS says if we use / or \ to seperate directories. It should be a URL like my second line of answer points out. Do you agree? – Grim May 04 '17 at 01:58
-
A File URI to the C: or D: drive is what I mean by an absolute path. An http or network share file URI would be fine. I personally would like to put a relative link to a resource file within the standard src/main/resources or src/test/resources directories. I think the base-path IS known actually, it would be the same base path used by getResourceAsStream("my-resource.json"). Anyway, I don't see this answering the question for a broader audience, but just the OP, yet were I to ask the same question would it not get marked a duplicate of this? Maybe I'll try – Novaterata May 04 '17 at 02:16
-
But it is a network-share-file-uri! the `file:///` is a shortcut for `file://localhost/`as you see here https://tools.ietf.org/html/rfc1738 in the line `fileurl = "file://" [ host | "localhost" ] "/" fpath`. Ah, now I understand the confusion, you thought I posted a absolute url, but I did not! – Grim May 04 '17 at 02:47
-
`As a special case,
can be the string "localhost" or the empty string; this is interpreted as 'the machine from which the URL is being interpreted'.` – Grim May 04 '17 at 02:54 -
I just checked, unfortunately it also doesn't work with `"classpath:easywords.txt"` (at least not on windows in IntelliJ, don't know if it does any place else) – Rik Schaaf Dec 26 '21 at 20:08
-
@RikSchaaf Yes, classpath: urls in javadoc might be a good suggestion. I fear the suggestion will be rejected. Javadoc is designed to be compleatly detached from the library itself. You could offer the Javadoc to a webserver and offer the source throu a webserver. Then you could link the javadoc to the source using the https/http sceme. – Grim Dec 27 '21 at 10:44
-
I guess this is the preferred and most widely used method. – Grim Dec 27 '21 at 10:54
-
@Grim true, but it would be nice to be able to click on it in your IDE and have it go to the file in your resources folder, for instance if you are writing property classes for a YML config file, it would be nice if you were able to link to that config file. – Rik Schaaf Dec 27 '21 at 22:21
-
@RikSchaaf Lol, I remember I wrote a eclipse-plugin called eclipselink (before the real eclipselink was invented). This plugin of mine started a socketserver on a specific port to handle urls that points to source-files. The urls was like **http://http://localhost:1234/myproject/HMan/easy.txt#5** and a click on this like opens the required file and mark the line 5. It did not ported to netbeans. – Grim Dec 28 '21 at 18:09