Eclipse won't compile/run java file

后端 未结 5 467
忘掉有多难
忘掉有多难 2021-01-01 12:15

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

相关标签:
5条回答
  • 2021-01-01 12:35

    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.

    0 讨论(0)
  • 2021-01-01 12:47

    This worked for me:

    1. Create a new project
    2. Create a class in it
    3. Add erroneous code, let error come
    4. Now go to your project
    5. Go to Problems window
    6. Double click on a error

    It starts showing compilation errors in the code.

    0 讨论(0)
  • 2021-01-01 12:50

    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!image for error fix view, see Excluded field

    0 讨论(0)
  • 2021-01-01 12:51

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

    0 讨论(0)
  • 2021-01-01 12:56
    • 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.

    Hollow J means it is not part of a project

    0 讨论(0)
提交回复
热议问题