Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the differences between javadoc.jar, sources.jar and .jar?

Tags:

java

Looking at Google gson 2.8.5 , I see several jars are distributed here https://repo1.maven.org/maven2/com/google/code/gson/gson/2.8.5/

  • gson-2.8.5-javadoc.jar
  • gson-2.8.5-sources.jar
  • gson-2.8.5.jar

By reading other posts, I understand that sources.jar contains source code, but jar contains the compiled class files.

  1. Does this mean that, given the sources.jar, I can generate the jar myself? What is the general relationship between these three jars?
  2. What is javadoc.jar? Does it only contain documentation, or source code / compiled classes too?
like image 809
Kevin Maxwell Avatar asked Jan 25 '19 19:01

Kevin Maxwell


People also ask

What is a javadoc jar?

The javadoc. jar contains a static html site which content is extracted from all the javadocs which are present in the Java source files.

What is a source jar?

That sources jar is a jar that contains only the source code (the . java files) corresponding to the compiled artifact. It is useful to add it as a source attachment in your IDE, to publish the sources, etc. As it only contains sources, not compiled classes (. class files), it is of no use as a library dependency.

How do I find javadoc jar?

jamdoc.jar To view an HTML documentation file, open your web browser and specify the file name of the javadoc you want to view, taken from the classdocs directory. Any of the following files are good for getting started: classdocs/AllNames. html.

Which command should you use to package javadoc into a jar file?

The “maven-javadoc” plugin uses “ JDK\bin\javadoc.exe ” command to generate javadocs, pack in jar file and deploy along with your project.


1 Answers

Does this mean that, given the sources.jar, I can generate the jar myself?

Yes, you could extract the Java code from the sources.jar using the jar command.

E.g. jar xf gson-2.8.5-sources.jar

And than compiling the Java files using javac.

But you need to have all the referenced dependencies in your classpath which are required when you call javac. These dependencies can be found in the project pom.xml

What is the general relationship between these three jars?

The .jar file contains the compliled code which is contained in the sources.jar. So using the sources.jar you could create the .jar yourself (as mentioned having the required dependencies). The javadoc.jar contains a static html site which content is extracted from all the javadocs which are present in the Java source files.

like image 144
brass monkey Avatar answered Oct 23 '22 17:10

brass monkey