简体   繁体   English

从特定jar导入类文件

[英]Import class file from specific jar

I am working with 2 jars , base.jar and derived.jar where I ordered it the class path in this way: base.jar and then derived.jar 我正在使用2个jar,base.jar和derived.jar,我以这种方式命令它的类路径:base.jar然后derived.jar

I have a problem that I have a class with the same name package in both jars it's third party that I can't change 我有一个问题,我在两个罐子里都有一个同名包装的类,这是我无法改变的第三方

And in code I want to import the class from the derived.jar with out change the class path order ? 在代码中我想从derived.jar导入类而不更改类路径顺序?

Is there an option to it in my code in the import command or by adding annotation? 我的代码中是否有导入命令或添加注释的选项?

thanks 谢谢

If you write your own classloader with a predictable jar loading order - yes. 如果您使用可预测的jar加载顺序编写自己的类加载器 - 是的。 But you should instead rename the class/package. 但您应该重命名类/包。

如果它是第三方并且你有源,你可以自己重构该类并重建jar。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM