Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between the Apache sources.jar and .jar files?

Tags:

java

apache

I'm curious about Apache commons-io, why do they include a sources-jar inside the code package. We will not compile the program like so :

javac -cp .;.\lib\commons-io-2.4-sources.jar  myCode.java

But we compile it like this :

javac -cp .;.\lib\commons-io-2.4.jar  myCode.java

So why do the libraries also include a -sources jar in the download code ? I'm guessing it's for studying the source code, if we want to add/improve ?

like image 629
Caffeinated Avatar asked Oct 17 '25 08:10

Caffeinated


1 Answers

The source JAR is so you can read the code is you want to. If you use an IDE, it can know to down load this JAR and if you look at a class in it, it will show your the source. esp useful when debugging a program. If you are not using an IDE, you can unpack the source and read it to understand what it is doing.

The reason the source is not included in the compiled JAR is so it can be easily dropped if all your are doing is running the program e.g. in production.

like image 162
Peter Lawrey Avatar answered Oct 19 '25 23:10

Peter Lawrey