javamavendocumentationjavadocmaven-publish

Why do we need both javadoc and sources jar?


Generally, when publishing a library, do we need both sources.jar and javadoc.jar? I don't really understand the purpose of javadoc.jar.If it's about the code documentation, the IDE can show it from sources.jar itself.

Example: enter image description here

Please note, this is not a duplicate of What are the differences between javadoc.jar, sources.jar and .jar?. I am looking for what javadoc.jar can do, that sources.jar can't.


Solution

  • Let me address the questions one by one:

    Why does javadoc.jar even exist if sources.jar can be used?

    This question basically addresses the developers. If the sources can't be shared (e.g. it might be proprietary) sharing the documentation is still going to help.

    Why do developers provide both?

    A very simple reason might be because that's the default for Maven, Gradle etc.

    Another reason might be that some organizations don't allow access to source code for security reasons (or others) or can't/don't want to build the HMTL files themselves but rather just host them.

    Why do I as a developer need to import javadoc.jar into my IDE if I can use sources.jar?

    I'd say you shouldn't need to. As a dev I often find it very useful to have the sources available for debugging etc. so I'd prefer source.jar.