java classpath中 jar包的顺序
高洛峰
高洛峰 2017-04-17 16:07:12
[Java讨论组]

举例说,

a.jar, b.jar 都有 MyTest这个类。

java -cp a.jar;b.jar ...

那么 这个MyTest 拿到的到底 是哪个jar包的?

经验表明 是cp前面的那个, 但没看到任何官方文档 描述这个。

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

全部回复(1)
PHPz

ok, 找到了。

https://docs.oracle.com/javase/8/docs/technotes/tools/unix/classpath.html

Specification Order

The order in which you specify multiple class path entries is
important. The Java interpreter will look for classes in the
directories in the order they appear in the class path variable. In
the previous example, the Java interpreter will first look for a
needed class in the directory /java/MyClasses. Only when it does not
find a class with the proper name in that directory will the
interpreter look in the /java/OtherClasses directory.

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号