compilation – Eclipse wont compile/run java file

compilation – Eclipse wont compile/run java file

  • 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 projects folder.
    • Find the project INSIDE Eclipses 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.


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.


compilation – Eclipse wont compile/run java file

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

Leave a Reply

Your email address will not be published.