如何使javac找到JAR文件? (Eclipse可以看到它们) [英] How to make javac find JAR files? (Eclipse can see them)
问题描述
javac
编译时,它表示我缺少一些包... 我复制了我的编译命令和下面的一些错误文本:
javac -classpath lib / -d bin / src / *。java
src / Cleaner.java:5:package net.sourceforge.jgeocoder不存在
src / MyUtilities.java:19:package org。 apache.commons.codec.binary不存在
在Eclipse中,我添加了所有的.JAR文件对于构建路径,程序编译很好。
为什么在使用javac而不是Eclipse IDE时找不到jar?
-classpath lib /
将导致 javac
在 lib
中查找一个类文件树。如果您有JAR存档,那么您必须使用 -classpath lib / *。jar
- 并且可能使用CLI在*上的任何转义机制来确保它达到 javac
而不是通过CLI扩展
请参阅 javac命令参考(windows)。
When I'm in Eclipse my project compiles with no errors, however when I try to compile with javac
it says I'm missing some packages...
I copied my compile command and some of the error text below:
javac -classpath lib/ -d bin/ src/*.java
src/Cleaner.java:5: package net.sourceforge.jgeocoder does not exist
src/MyUtilities.java:19: package org.apache.commons.codec.binary does not exist
In Eclipse, I have added all the .JAR files to the build-path, and the program compiles just fine.
Why can it not find the jars when I use javac instead of the Eclipse IDE?
-classpath lib/
will cause javac
to look for a tree of class files in lib
. If you have JAR archives there, you have to use -classpath lib/*.jar
- and probably use whatever escaping mechanism your CLI has on the * to make sure it reaches javac
rather than being expanded by the CLI
See the javac command reference (windows).
这篇关于如何使javac找到JAR文件? (Eclipse可以看到它们)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!