Eclipse won't compile/run java file
Solution 1
- 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.
Solution 2
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!
Solution 3
right click somewhere on the file or in project explorer and choose 'run as'->'java application'
Jess Anastasio
Updated on August 04, 2022Comments
-
Jess Anastasio over 1 year
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.