在 Eclipse 中使用 Ant 时出现运行 javac.exe 编译器消息时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3394369/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 22:53:30  来源:igfitidea点击:

Getting Error running javac.exe compiler message, while using Ant in Eclipse

javaeclipseantbuild

提问by Veera

When I run my Ant build in Eclipse, I'm getting the following error message and the Ant build fails.

当我在 Eclipse 中运行 Ant 构建时,我收到以下错误消息并且 Ant 构建失败。

Error Message:Error running javac.exe compiler

错误信息:运行 javac.exe 编译器时出错

Line where the build stops:

构建停止的行:

<javac destdir="${classes.home}" debug="on" fork="true" memoryinitialsize="512M" memorymaximumsize="1G">
        <classpath refid="classpath"/>
        <src path="${source.home}"/>
</javac>

Has anyone faced a similar problem before? or does anybody know what's wrong here?

有没有人遇到过类似的问题?或者有人知道这里出了什么问题吗?

System Information: Eclipse Helio, JDK 1.5

系统信息:Eclipse Helio,JDK 1.5

采纳答案by spbala

I had the same problem and the issue was, in eclipse java.home was referring to JRE instead of JDK. I changed it and the build was successful. You can do the following to change it to JDK:

我遇到了同样的问题,问题是,在 eclipse java.home 中指的是 JRE 而不是 JDK。我改变了它,构建成功。您可以执行以下操作将其更改为 JDK:

Preferences > Java > Installed JRE's > Add... For 'JRE Type' select 'Standard VM' > Next > Directory: select your JDK directory (instead of JRE) (in my case: C:\Program Files\Java\jdk1.6.0_16 ), press OK.

Preferences > Java > Installed JRE's > Add... 对于'JRE Type'选择'Standard VM' > Next > Directory:选择你的JDK目录(而不是JRE)(在我的例子中:C:\Program Files\Java\jdk1. 6.0_16 ),按确定。

Now, you are back at 'Installed JRE's', select the JDK here also.

现在,您返回到“已安装的 JRE”,在这里也选择 JDK。

The below post helped in finding the solution. JAVA_HOME points to the wrong place

下面的帖子有助于找到解决方案。 JAVA_HOME 指向错误的地方

回答by Impiastro

Maybe the javac problem is because "javac.exe" is not in your System PATH, please edit your system path and add your JDK's /bin directory to it to correct this problem.

可能 javac 问题是因为“javac.exe”不在您的系统路径中,请编辑您的系统路径并将您的 JDK 的 /bin 目录添加到其中以更正此问题。

Open a shell or command prompt and try typing: javac to check if the system path is set correctly.

打开 shell 或命令提示符并尝试键入:javac 以检查系统路径是否设置正确。

回答by fuwaneko

Try changing memorymaximumsize="1G" to memorymaximumsize="512M".

尝试将 memorymaximumsize="1G" 更改为 memorymaximumsize="512M"。

回答by pall

Configuring eclipse to point to JDK instead of JRE did not work for me. With further investigation, I solved this problem by stopping the build process from forking. In your build.xml, remove the attribute forkfrom <javac>tag.

将 eclipse 配置为指向 JDK 而不是 JRE 对我不起作用。通过进一步调查,我通过停止分叉构建过程解决了这个问题。在您的 build.xml 中,fork<javac>标记中删除该属性。

回答by Avinash

I had the same problem and removed the attribute fork from javac and problem was gone.

我遇到了同样的问题并从 javac 中删除了属性叉,问题就消失了。

回答by knb

Try to free some main memory. Close memory-hungry programs, and stop memory-hungry processes if you can.

尝试释放一些主内存。关闭占用大量内存的程序,并尽可能停止占用大量内存的进程。

回答by Abhi Rampal

If the accepted answer above doesn't solve the problem for you (as it didn't for me), after updating the java.home to JDK instead of JRE as suggested in the accepted answer above, Go to Run -> External Tools -> External Tools Configuration -> select your build.xml on the left menu -> select JRE tab -> select the JDK(from the dropdown) for Separate JRE radio button option -> Click Run.

如果上面接受的答案没有为您解决问题(因为它没有为我解决),在按照上面接受的答案中的建议将 java.home 更新为 JDK 而不是 JRE 之后,转到运行 -> 外部工具 - > 外部工具配置 -> 在左侧菜单中选择您的 build.xml -> 选择 JRE 选项卡 -> 为单独的 JRE 单选按钮选项选择 JDK(从下拉列表中) -> 单击运行。

This should fix the problem.

这应该可以解决问题。

回答by Uriel Frankel

I solved this by checking my Environment Variables in my Windows 7. I found that JAVA_HOMEis pointing to C:\ Program Files (x86)\Java\jdk1.6.0_31 when it supposed be C:\ Program Files\Java\jdk1.6.0_31. If you want to know how read this

我通过检查 Windows 7 中的环境变量解决了这个问题。我发现JAVA_HOME指向 C:\ Program Files (x86)\Java\jdk1.6.0_31,而它应该是 C:\ Program Files\Java\jdk1.6.0 _31. 如果你想知道如何阅读这篇文章

回答by Ahmed Hamdy

I've tried everything but nothing worked for me till I've set (fork='no'or fork='false' in your case) and worked for me perfectly

我已经尝试了所有方法,但在我设置之前没有任何效果(在您的情况下是fork='no'或 fork='false')并且完美地为我工作

回答by Scala Enthusiast

I removed fork="true" and I got past that piece of code. What might be interesting to those of you who have this problem is that now, at that line, I get the output:

我删除了 fork="true" 并且我通过了那段代码。有这个问题的人可能会感兴趣的是,现在,在该行,我得到了输出:

'Since fork is false, ignoring memoryMaximumSize setting.'

So it may be an issue with memoryMaximumSize if you need to keep your fork="true" setting, as suggested above.

所以如果你需要保持你的 fork="true" 设置,这可能是 memoryMaximumSize 的问题,如上所述。