Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a sources JAR?

Tags:

I was recently trying to import a library to use for something I am working on.

https://sites.google.com/site/piotrwendykier/software/jtransforms

I was having some difficulty because the JAR that I added to the build path was the "JTransforms-3.0-sources.jar" and not the "JTransforms-3.0.jar".

Now I am sort of scratching my head and just wondering what that first sources.jar was if it didn't have any of the classes that I wanted to use in it.

What is it and what is it for?

like image 322
Nathan Avatar asked Jun 06 '15 18:06

Nathan


People also ask

How do I create a source jar?

The source plugin can be used to create a jar file of the project sources from the command line or by binding the goal to the project's build lifecycle. To generate the jar from the command line, use the following command: mvn source:jar.

What does jar mean in files?

JAR stands for Java ARchive. It's a file format based on the popular ZIP file format and is used for aggregating many files into one.

How do I view the source of a JAR file?

Jar files are archive files that contains of a lot of different java classes (files). You can use winzip/winrar to open the jar files and you can see those java classes in jar files. Typically you can use a Java decompiler to decompile the class file and look into the source code.


1 Answers

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.

like image 92
jotadepicas Avatar answered Sep 22 '22 14:09

jotadepicas