I see many Java packages have api, impl and bundle jars (name-api.jar, name-impl.jar, name-bundle.jar). Could someone explain what those mean? Are all three needed by the ap
I've never seen such an arrangement.
If the designer packaged the app into three JARs, then I'd say all three are needed.
But you should recognize that it's just a choice made by the designer. It's possible that s/he could have just created a single JAR with everything in it and you'd be none the wiser.
I'm guessing now, but if you were to open those JARs you'd see only interfaces in the API JAR, implementations of those interfaces in the impl JAR, and resource bundles and other .properties files in the bundle JAR. Try it and see. You'll learn something.
api.jar
contains API interfaces. These are interfaces as a contract that the implementation of the API should follow.
impl.jar
is the implementation of the api.jar
. You can't just have the impl.jar
without the api.jar
.
bundle.jar
is the resources (if I'm not mistaken). Those are resources needed for the implementation code necessary to run.
Often :
name-api.jar
contains only the interface of the API.name-impl.jar
provides an implementation of all interfaces in the name-api.jarname-bundle.jar
bundles everything with all the needed classes to run a Java application.The idea is that you can separate the dependencies of the application; in an attempt to make applications more portable. The idea is that you can make the application dependent on the api.jar
when compiling. Then when you want to run the program you can then switch in the appropriate implementation jar (impl.jar
) and the appropriate resource bundle jar (bundle.jar
).
As an example suppose the library does some database interaction. You write your code so that it references the api.jar
. Now suppose you need it to work with a specific type of database e.g. MySQL - you would then add the impl.jar
that is specific to MySQL databases to the classpath to get it to work (if you need a different database later - you only need to switch that jar in the classpath).
The bundle.jar
is a bit more obscure and not as common. This could be used to supply configuration setting for the library. For example it could be used to supply language specific settings, or some more specific config. In the case of the database library it might be that the implementation is designed for all versions of MySQL, and the resource bundle jar provides config files that allow it to work for a specific MySQL version.