简体   繁体   English

如何编译具有jar依赖项的java文件?

[英]How do I compile a java file that has jar dependencies?

I have a helper lib that I wrote to sit on top of Apache Commons, and when I try to javac it (so that I can make it into a jar) it complains, quite reasonably, that it has no idea what I'm talking about when I make reference to the stuff that's in the commons.jar. 我有一个帮助库,我写的是坐在Apache Commons之上,当我尝试javac它(这样我就可以把它变成一个罐子里)它很合理地抱怨它不知道我在说什么当我参考commons.jar中的东西时。

How does one include a jar so as that javac can compile? 如何包含一个jar,以便javac可以编译?

For windows: 对于Windows:

javac -cp ".;/dir/commons.jar;/dir/more_jar_files.jar" MyClass.java

For unix or mac (thanks for the tip Dawood): 对于unix或mac(感谢提示Dawood):

javac -cp ".:/dir/commons.jar:/dir/more_jar_files.jar" MyClass.java

Which means: 意思是:

javac -cp <path to jar> MyClass.java

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

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