如何使javac找到JAR文件? (Eclipse可以看到它们) [英] How to make javac find JAR files? (Eclipse can see them)

查看:121
本文介绍了如何使javac找到JAR文件? (Eclipse可以看到它们)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在Eclipse中,我的项目编译没有错误,但是当我尝试使用 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆