I am just trying to compile and run a simple java program. When I go to run my tester class it says select what to run and it gives me Ant Build which when highlighted says "Launches an Ant build with default settings" or Ant Build... that says "Launches an Ant build and allows it to be configured". When I try to select either of these it prompts Build failed. Reason: Unable to find ant file to run. I honestly don't know what these ant builds and files are. This is definitely a dumb question but have no idea what to do.
-
Is that file inside a project? – Christian Tapia Jan 11 '14 at 22:02
7 Answers
- Make a project to put the files in.
- File -> New -> Java Project
- Make note of where that project was created (where your "workspace" is)
- Move your java files into the
src
folder which is immediately inside the project's folder.- Find the project INSIDE Eclipse's Package Explorer (Window -> Show View -> Package Explorer)
- Double-click on the project, then double-click on the 'src' folder, and finally double-click on one of the java files inside the 'src' folder (they should look familiar!)
- Now you can run the files as expected.
Note the hollow 'J' in the image. That indicates that the file is not part of a project.

- 870
- 1
- 13
- 22
-
1Surprisingly still relevant. Today it might be helpful to new users to add a note to click "Do not create" at the "Create a new module-info.java file". – LabGecko Jan 28 '20 at 15:16
I was also in the same problem, check your build path in eclipse by Right Click on Project > build path > configure build path
Now check for Excluded Files, it should not have your file specified there by any means or by regex.
Cheers!

- 921
- 11
- 24
right click somewhere on the file or in project explorer and choose 'run as'->'java application'

- 11,228
- 6
- 27
- 42
This worked for me:
- Create a new project
- Create a class in it
- Add erroneous code, let error come
- Now go to your project
- Go to Problems window
- Double click on a error
It starts showing compilation errors in the code.

- 6,801
- 5
- 32
- 55
Your project has to have a builder set for it. If there is not one Eclipse will default to Ant. Which you can use you have to create an Ant build file, which you can Google how to do. It is rather involved though. This is not required to run locally in Eclipse though. If your class is run-able. It looks like yours is, but we can not see all of it.
If you look at your project build path do you have an output folder selected? If you check that folder have the compiled class files been put there? If not the something is not set in Eclpise for it to know to compile. You might check to see if auto build is set for your project.

- 1,793
- 1
- 18
- 26
-
Hey thanks for your help! I created these java classes in Dr. Java and have them saved on my computer... I simply opened them using Eclipse so maybe because they weren't originally created on eclipse they won't compile? Im not sure. I don't know how to check the project build path.. Thanks again!! – Jess Anastasio Jan 14 '14 at 05:36
What I did was I created a new project and opened the file location from my old project and new one. Then I copied everything from the old project besides the run file, and ran it on the new project and now it works fine.

- 1
-
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Sep 23 '21 at 00:52
the file is probably located in your project package but is not yet compiled so you are able to open it as a java file in your eclipse java project, here is what I did in my case: in eclipse, goto terminal window, cd to your project directory, then cd to your project package, then run javac yourFileName.java, finally right click your java project or project package in the project explorer and... you should see the file there, and it should now run for you as a java file... hope this helps!!!

- 1