运行时的 Java 类路径
我正在程序中导入 import org.apache.commons.httpclient.*;
,但每当我要运行它时,我都必须将 JAR 包含在类路径中。为什么这是必要的?有什么办法可以解决这个问题吗?
I am importing import org.apache.commons.httpclient.*;
in a program, but whenever I go to run it, I have to include the JAR in the classpath. Why is this necessary? Are there any ways around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我怀疑它就像 Tomcat 一样简单,因为它是一个 Web 服务器,它(它 == java 人)认为制作 servlet 的人需要并想要链接库,但这对于普通的独立 java 应用程序来说是多余的。也许有一天它会成为 JRE 本身的一部分?
默认情况下它也可能包含在 Tomcat 的 lib/ 文件夹中 - 我不确定。
I suspect that it's as simple as Tomcat, by virtue of being a web server, links libraries that it (it == the java people) think that people making servlets will need and want but that would be superfluous for normal standalone java apps. Maybe one day it'll become a part of the JRE itself?
It might also be included in Tomcat's lib/ folder by default - I'm not sure.