目的是:api.jar + impl.jar + bundle.jar? [英] What's the purpose: api.jar + impl.jar + bundle.jar?

查看:49
本文介绍了目的是:api.jar + impl.jar + bundle.jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到许多Java软件包都有api,impl和bundle jar(name-api.jar,name-impl.jar,name-bundle.jar).有人可以解释这些意思吗?该应用程序是否需要这三个条件?

解决方案

其思想是您可以分离应用程序的依赖关系.试图使应用程序更具可移植性.这个想法是,您可以在编译时使应用程序依赖于 api.jar .然后,当您要运行该程序时,可以切换到相应的实现jar( impl.jar )和相应的资源束jar( bundle.jar ).

作为一个示例,假设库进行了一些数据库交互.您编写代码,使其引用 api.jar .现在假设您需要它与特定类型的数据库一起使用,例如MySQL-然后将特定于MySQL数据库的 impl.jar 添加到类路径中,以使其正常工作(如果以后需要其他数据库,则只需在类路径中切换该jar).

bundle.jar 有点晦涩,并不常见.这可用于提供库的配置设置.例如,它可用于提供特定于语言的设置,或提供一些更特定的配置.对于数据库库,可能是针对所有版本的MySQL设计实现的,并且资源束jar提供了允许其在特定MySQL版本上工作的配置文件.

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?

解决方案

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.

这篇关于目的是:api.jar + impl.jar + bundle.jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆