Ant 构建不起作用:无法找到 javac 编译器 [英] Ant build not working: unable to find a javac compiler

查看:36
本文介绍了Ant 构建不起作用:无法找到 javac 编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一些 Java EE 示例.Ant 提示:也许 JAVA_HOME 没有指向 JDK.当前设置为C:\Program Files\Java\jre7

I am trying to run some Java EE examples. Ant is suggesting: Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre7

我的 JAVA_HOME 变量是:C:\Program Files\Java\jdk1.7.0_03 当我查看 Windows 7 变量时

My JAVA_HOME variable is: C:\Program Files\Java\jdk1.7.0_03 when I look at my windows 7 variables

然而,我的路径是(注意 jdk1.6.0_26):

However, my path is (notice the jdk1.6.0_26):

%M2_HOME%\bin;%ANT_HOME%\bin;%JAVA_HOME%\bin;%SystemRoot%\system32;%SystemRoot%;
%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\Program Files\Microsoft Application Virtualization Client;%M2%;
C:\Program Files\QuickTime\QTSystem\;C:\Program Files\TortoiseSVN\bin;
%GLASSFISH%;%GLASSFISH_PARENT%;

PATH=C:\Maven\apache-maven-2.2.1\bin;C:\Ant\apache-ant-1.8.2\bin;**C:\Program File
s\Java\jdk1.6.0_26\bin;**C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C
:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft Applicatio
n Virtualization Client;C:\Maven\apache-maven-2.2.1\bin;C:\Program Files\QuickTi
me\QTSystem\;C:\Program Files\TortoiseSVN\bin;C:\glassfish3\glassfish\bin;C:\gla
ssfish3\bin;C:\Sun\jwsdp-2.0\jwsdp-shared\bin

我需要做什么特别的事情才能让 Windows 保存我的路径吗?

Do I have to do anything special to get windows to save my path?

更多信息:

C:\javaeetutorial5\examples\web\hello2>ant
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre7\li
b\tools.jar
Buildfile: C:\javaeetutorial5\examples\web\hello2\build.xml

-pre-init:

init:

default-ear:

-pre-compile:

bpp-actual-compilation:
     [echo] Compiling hello2
     [echo] javaee.classpath.prefix is: C:\glassfish3/lib
     [echo] is.glassfish.v3 is: ${is.glassfish.v3}
    [javac] C:\javaeetutorial5\examples\bp-project\command-line-ant-tasks.xml:93
: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=las
t; set to false for repeatable builds

BUILD FAILED
C:\javaeetutorial5\examples\bp-project\command-line-ant-tasks.xml:93: 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 "C:\Program Files\Java\jre7"

Total time: 0 seconds

推荐答案

对于 eclipse

For eclipse

  • 右键单击 build.xml ---> 构建路径 ---> 配置构建路径 ---> 选择库选项卡
  • 点击添加库"--->双击[jre系统库]--->环境--->安装的jres--->添加--->标准vm
  • 点击目录 ---> 浏览到 jdk [C:\Program Files\Java\jdk1.7.0_01]
  • 完成
  • 将选择 jre 更改为 jdk ---> 单击确定

这篇关于Ant 构建不起作用:无法找到 javac 编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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