如何编译具有jar依赖项的java文件? [英] How do I compile a java file that has jar dependencies?
本文介绍了如何编译具有jar依赖项的java文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个帮助库,我写的是坐在Apache Commons之上,当我尝试javac它(这样我可以把它变成一个罐子里)时,它抱怨,很合理,它不知道我是什么在谈论commons.jar中的内容时,我正在谈论。
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.
如何包含jar以便javac可以编译?
How does one include a jar so as that javac can compile?
推荐答案
对于Windows:
javac -cp ".;/dir/commons.jar;/dir/more_jar_files.jar" MyClass.java
对于unix或mac(感谢提示Dawood):
For unix or mac (thanks for the tip Dawood):
javac -cp ".:/dir/commons.jar:/dir/more_jar_files.jar" MyClass.java
这意味着:
javac -cp <path to jar> MyClass.java
这篇关于如何编译具有jar依赖项的java文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文