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 app?
A rest API written in Java will return a JSON payload which can then be read and used by an application written in any programming language. This is the advantage of web services. A jar will return Java objects as a payload, so is optimal to use if you will be using it exclusively within other Java applications.
JAR files are packaged with the ZIP file format, so you can use them for tasks such as lossless data compression, archiving, decompression, and archive unpacking. These tasks are among the most common uses of JAR files, and you can realize many JAR file benefits using only these basic features.
A JAR ("Java archive") file is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution. Java Archive.
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.
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.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With