从命令行通过 ant 构建 java eclipse 项目时出错
我正在尝试通过命令行使用 ant 构建一个 Eclipse 项目。当我在 java 中运行 build.xml 文件时效果很好,但是当我 cd 到项目目录(build.xml 所在的位置)并运行 ant -f build.xml
时,出现以下错误msg:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Buildfile: build.xml
clean:
[delete] Deleting directory /home/adam/workspace/pfaat/classes
build:
[mkdir] Created dir: /home/adam/workspace/pfaat/classes
[javac] Compiling 502 source files to /home/adam/workspace/pfaat/classes
BUILD FAILED
/home/adam/workspace/pfaat/build.xml:86: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"
Total time: 0 seconds
有没有办法让我从命令行指定编译器而不更改 build.xml?再说一遍,当我用 eclipse 运行它时,它工作得很好,而且我在 eclipse 或 ant 手册中没有找到任何表明它不会工作的内容。顺便说一句,我运行的是 ubuntu 10.04。非常感谢您抽出时间。 亚当
I'm trying to build an eclipse project with ant via the command line. The build.xml file works great when I run it in java, but when I cd to the project directory(where build.xml is located) and run ant -f build.xml
I get the following error msg:
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-openjdk/lib/tools.jar
Buildfile: build.xml
clean:
[delete] Deleting directory /home/adam/workspace/pfaat/classes
build:
[mkdir] Created dir: /home/adam/workspace/pfaat/classes
[javac] Compiling 502 source files to /home/adam/workspace/pfaat/classes
BUILD FAILED
/home/adam/workspace/pfaat/build.xml:86: Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK.
It is currently set to "/usr/lib/jvm/java-6-openjdk/jre"
Total time: 0 seconds
Is there a way for me to specify the compiler from the command line w/o changing the build.xml? Again, it works fine when I run it with eclipse, and I haven't found anything in the eclipse or ant manual that should suggest it wouldn't. BTW, I'm running ubuntu 10.04. Thank you very much for your time.
Adam
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置指向tools.jar的PATH确保它有
tools.jar
文件使用
set PATH that points to tools.jar make sure that it have
tools.jar
fileuse
您的 JAVA HOME 路径设置为您的 JRE。 Ant 需要 JDK 才能从命令行工作。
Your JAVA HOME path is set to your JRE. Ant needs JDK to work from command line.