Javadoc link to src/main/resource or src/test/resource file using relative path












12















I would find it extremely useful if there was a way to put a link in javadoc to a standard resource file that resides in src/main/resources or src/test/resources so that another coder could quickly navigate to the resource file (in this case a JSON file).



These files are used in unit tests and need to be modified often as the schema changes.



The answer here Link to text file (resource) in Javadoc does not help as an absolute path would be too fragile.



Is there a way to do the same thing as @see with resources?
Something specific to IntelliJ would be great if javadoc itself falls short.










share|improve this question





























    12















    I would find it extremely useful if there was a way to put a link in javadoc to a standard resource file that resides in src/main/resources or src/test/resources so that another coder could quickly navigate to the resource file (in this case a JSON file).



    These files are used in unit tests and need to be modified often as the schema changes.



    The answer here Link to text file (resource) in Javadoc does not help as an absolute path would be too fragile.



    Is there a way to do the same thing as @see with resources?
    Something specific to IntelliJ would be great if javadoc itself falls short.










    share|improve this question



























      12












      12








      12


      2






      I would find it extremely useful if there was a way to put a link in javadoc to a standard resource file that resides in src/main/resources or src/test/resources so that another coder could quickly navigate to the resource file (in this case a JSON file).



      These files are used in unit tests and need to be modified often as the schema changes.



      The answer here Link to text file (resource) in Javadoc does not help as an absolute path would be too fragile.



      Is there a way to do the same thing as @see with resources?
      Something specific to IntelliJ would be great if javadoc itself falls short.










      share|improve this question
















      I would find it extremely useful if there was a way to put a link in javadoc to a standard resource file that resides in src/main/resources or src/test/resources so that another coder could quickly navigate to the resource file (in this case a JSON file).



      These files are used in unit tests and need to be modified often as the schema changes.



      The answer here Link to text file (resource) in Javadoc does not help as an absolute path would be too fragile.



      Is there a way to do the same thing as @see with resources?
      Something specific to IntelliJ would be great if javadoc itself falls short.







      java intellij-idea resources javadoc






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 23 '17 at 11:47









      Community

      11




      11










      asked May 4 '17 at 2:22









      NovaterataNovaterata

      2,161927




      2,161927
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Not quite an answer but a feature of IDE:



          If you use Intellij IDEA, it is possible out-of-the-box. Where you load the file you must specify the path, right? So you Ctrl+click on a path and Intellij just brings you to the file.



          The path is relative to the classpath so you have portability.



          It requires all the team members to use Intellij, yes, not a global solution, not a "literal" solution.



          Check this:



          enter image description here






          share|improve this answer
























          • But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

            – Novaterata
            Nov 23 '18 at 12:44











          • But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

            – WesternGun
            Nov 23 '18 at 13:47













          • That's not a relative path, it begins with a slash.

            – Novaterata
            Nov 23 '18 at 14:54













          • In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

            – WesternGun
            Nov 26 '18 at 8:26













          • I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

            – Novaterata
            Nov 26 '18 at 14:03



















          2














          No need to mention the absolute path. See my package and class structure below. From a sister package if I follow the URI rules I do a .. to go one folder back and mention it like this. It works! On clicking the url the file opens. Although I have illustrated this in eclipse, I think this should be IDE agnostic.



          /**
          * Removes all the stop words like a, for, the etc. from the text. For a
          * full list of stop words check
          * <a href="file:../resources/stopWords.txt">/resources/stopWords.txt</a>
          *
          * @return String free of all the stop-words
          * @param text
          * The string to be cleaned, do null check at your end
          */


          enter image description here



          Package Structure






          share|improve this answer
























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43772805%2fjavadoc-link-to-src-main-resource-or-src-test-resource-file-using-relative-path%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Not quite an answer but a feature of IDE:



            If you use Intellij IDEA, it is possible out-of-the-box. Where you load the file you must specify the path, right? So you Ctrl+click on a path and Intellij just brings you to the file.



            The path is relative to the classpath so you have portability.



            It requires all the team members to use Intellij, yes, not a global solution, not a "literal" solution.



            Check this:



            enter image description here






            share|improve this answer
























            • But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

              – Novaterata
              Nov 23 '18 at 12:44











            • But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

              – WesternGun
              Nov 23 '18 at 13:47













            • That's not a relative path, it begins with a slash.

              – Novaterata
              Nov 23 '18 at 14:54













            • In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

              – WesternGun
              Nov 26 '18 at 8:26













            • I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

              – Novaterata
              Nov 26 '18 at 14:03
















            1














            Not quite an answer but a feature of IDE:



            If you use Intellij IDEA, it is possible out-of-the-box. Where you load the file you must specify the path, right? So you Ctrl+click on a path and Intellij just brings you to the file.



            The path is relative to the classpath so you have portability.



            It requires all the team members to use Intellij, yes, not a global solution, not a "literal" solution.



            Check this:



            enter image description here






            share|improve this answer
























            • But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

              – Novaterata
              Nov 23 '18 at 12:44











            • But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

              – WesternGun
              Nov 23 '18 at 13:47













            • That's not a relative path, it begins with a slash.

              – Novaterata
              Nov 23 '18 at 14:54













            • In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

              – WesternGun
              Nov 26 '18 at 8:26













            • I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

              – Novaterata
              Nov 26 '18 at 14:03














            1












            1








            1







            Not quite an answer but a feature of IDE:



            If you use Intellij IDEA, it is possible out-of-the-box. Where you load the file you must specify the path, right? So you Ctrl+click on a path and Intellij just brings you to the file.



            The path is relative to the classpath so you have portability.



            It requires all the team members to use Intellij, yes, not a global solution, not a "literal" solution.



            Check this:



            enter image description here






            share|improve this answer













            Not quite an answer but a feature of IDE:



            If you use Intellij IDEA, it is possible out-of-the-box. Where you load the file you must specify the path, right? So you Ctrl+click on a path and Intellij just brings you to the file.



            The path is relative to the classpath so you have portability.



            It requires all the team members to use Intellij, yes, not a global solution, not a "literal" solution.



            Check this:



            enter image description here







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Nov 23 '18 at 9:36









            WesternGunWesternGun

            2,2011640




            2,2011640













            • But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

              – Novaterata
              Nov 23 '18 at 12:44











            • But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

              – WesternGun
              Nov 23 '18 at 13:47













            • That's not a relative path, it begins with a slash.

              – Novaterata
              Nov 23 '18 at 14:54













            • In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

              – WesternGun
              Nov 26 '18 at 8:26













            • I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

              – Novaterata
              Nov 26 '18 at 14:03



















            • But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

              – Novaterata
              Nov 23 '18 at 12:44











            • But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

              – WesternGun
              Nov 23 '18 at 13:47













            • That's not a relative path, it begins with a slash.

              – Novaterata
              Nov 23 '18 at 14:54













            • In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

              – WesternGun
              Nov 26 '18 at 8:26













            • I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

              – Novaterata
              Nov 26 '18 at 14:03

















            But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

            – Novaterata
            Nov 23 '18 at 12:44





            But a resource isn't relative to the classpath, it's relative to the package it's being loaded in

            – Novaterata
            Nov 23 '18 at 12:44













            But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

            – WesternGun
            Nov 23 '18 at 13:47







            But you put all the JSON under src/java/resources, no? If you load with Class.getResourcesAsStream("/xxx/xxx"), you specify the relative path of this resource relative to "resources". For example, if you have /src/java/resources/data/myfile.json, you load with getClass().getResourcesAsStream("/data/myfile.json");

            – WesternGun
            Nov 23 '18 at 13:47















            That's not a relative path, it begins with a slash.

            – Novaterata
            Nov 23 '18 at 14:54







            That's not a relative path, it begins with a slash.

            – Novaterata
            Nov 23 '18 at 14:54















            In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

            – WesternGun
            Nov 26 '18 at 8:26







            In the parameter of this method, the relative path begins with a /. Check another answer of mine: stackoverflow.com/questions/16374235/… and the javadoc of this method: docs.oracle.com/javase/8/docs/api and search "java.lang.Class", getResourcesAsStream().

            – WesternGun
            Nov 26 '18 at 8:26















            I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

            – Novaterata
            Nov 26 '18 at 14:03





            I've been on vacation, I'll check if this works for my use case when I'm in the office tomorrow, thanks for your insight

            – Novaterata
            Nov 26 '18 at 14:03













            2














            No need to mention the absolute path. See my package and class structure below. From a sister package if I follow the URI rules I do a .. to go one folder back and mention it like this. It works! On clicking the url the file opens. Although I have illustrated this in eclipse, I think this should be IDE agnostic.



            /**
            * Removes all the stop words like a, for, the etc. from the text. For a
            * full list of stop words check
            * <a href="file:../resources/stopWords.txt">/resources/stopWords.txt</a>
            *
            * @return String free of all the stop-words
            * @param text
            * The string to be cleaned, do null check at your end
            */


            enter image description here



            Package Structure






            share|improve this answer




























              2














              No need to mention the absolute path. See my package and class structure below. From a sister package if I follow the URI rules I do a .. to go one folder back and mention it like this. It works! On clicking the url the file opens. Although I have illustrated this in eclipse, I think this should be IDE agnostic.



              /**
              * Removes all the stop words like a, for, the etc. from the text. For a
              * full list of stop words check
              * <a href="file:../resources/stopWords.txt">/resources/stopWords.txt</a>
              *
              * @return String free of all the stop-words
              * @param text
              * The string to be cleaned, do null check at your end
              */


              enter image description here



              Package Structure






              share|improve this answer


























                2












                2








                2







                No need to mention the absolute path. See my package and class structure below. From a sister package if I follow the URI rules I do a .. to go one folder back and mention it like this. It works! On clicking the url the file opens. Although I have illustrated this in eclipse, I think this should be IDE agnostic.



                /**
                * Removes all the stop words like a, for, the etc. from the text. For a
                * full list of stop words check
                * <a href="file:../resources/stopWords.txt">/resources/stopWords.txt</a>
                *
                * @return String free of all the stop-words
                * @param text
                * The string to be cleaned, do null check at your end
                */


                enter image description here



                Package Structure






                share|improve this answer













                No need to mention the absolute path. See my package and class structure below. From a sister package if I follow the URI rules I do a .. to go one folder back and mention it like this. It works! On clicking the url the file opens. Although I have illustrated this in eclipse, I think this should be IDE agnostic.



                /**
                * Removes all the stop words like a, for, the etc. from the text. For a
                * full list of stop words check
                * <a href="file:../resources/stopWords.txt">/resources/stopWords.txt</a>
                *
                * @return String free of all the stop-words
                * @param text
                * The string to be cleaned, do null check at your end
                */


                enter image description here



                Package Structure







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 28 '17 at 7:15









                Ab SinAb Sin

                442413




                442413






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f43772805%2fjavadoc-link-to-src-main-resource-or-src-test-resource-file-using-relative-path%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

                    Alcedinidae

                    RAC Tourist Trophy