我尝试在 Eclipse 中运行 Java,它要求我选择 ant build,我选择的任何一个都说无法找到要运行的 ant 文件...
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30340486/
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
I tried to run Java in Eclipse and it asks me to select ant build and either one I choose it says unable to find ant file to run...
提问by Mandy
So I just installed JRE, JDK and Eclipse and I was trying to run this famous HelloWorld code, but it shows this message as in attached images. What's the ant build?
所以我刚刚安装了 JRE、JDK 和 Eclipse,我试图运行这个著名的 HelloWorld 代码,但它在附加图像中显示了这条消息。蚂蚁的结构是什么?
Thanks!
谢谢!
回答by Alaa Abuzaghleh
dont run it as ant, right click on your file in eclipse select run as then choose java application
不要将它作为 ant 运行,在 eclipse 中右键单击您的文件,选择 run as 然后选择 java application
回答by mikrasov
It looks like you don't have your file in your buildpath (what eclipse uses to figure out what files it should compile). Right click on the folder and select Buildpath -> Use as Source folder. Now when you hit run it should hopefully work.
看起来您的构建路径中没有您的文件(eclipse 使用什么来确定它应该编译哪些文件)。右键单击该文件夹并选择 Buildpath -> 用作源文件夹。现在当你点击运行它应该有希望工作。
回答by Sumit Singh
You are trying to run your program as ant build which is wrong.
您正试图将您的程序作为 ant build 运行,这是错误的。
See Eclipse Doc: Running your programs
Use Right click
on your source file and choose Run As-> Java Application
or
使用Right click
您的源文件,并选择Run As-> Java Application
或
- Select
"Run -> Run Configurations"
from the menu. - Search for you project in the list on the left and select it.
- Select the "Arguments" tab on the right.
- Write the argument you want to pass to the programm in "Programm arguments".
- Click
"Run"
- 选择
"Run -> Run Configurations"
从菜单。 - 在左侧列表中搜索您的项目并选择它。
- 选择右侧的“参数”选项卡。
- 在“程序参数”中写入要传递给程序的参数。
- 点击
"Run"
回答by Manoj M J
Try to create a Java class file with suitable name and method.This error usually occurs when compiler doesn't understand which file to execute.
尝试用合适的名称和方法创建一个Java类文件。这个错误通常发生在编译器不知道要执行哪个文件时。