Eclipse can't find / load main class

前端 未结 20 2089
猫巷女王i
猫巷女王i 2020-12-05 04:40

My Eclipse (Indigo) was running just fine. I created a simple class Hello. It is placed in package cont in the folder ch13. However

相关标签:
20条回答
  • 2020-12-05 05:04

    You must have main function in your class. Like

    public class MyDataBase {
    
    public static void main(String args[]) {
    
    }
    }
    
    0 讨论(0)
  • 2020-12-05 05:05

    I solved this error by closing the project, removing it from eclipse and then importing it again.

    Might be a little simpler than to redo the whole workspace setup.

    0 讨论(0)
  • 2020-12-05 05:07

    I have solved the issue following way:

    Go to Run Configuration (Right Click on Java File->Run->Run Configuration).

    Go to ClassPath Tab: Click on Advanced -> Add Folders -> Add bin directory (which has class file in it for Java source code)

    Re run the code, now it will solve the issue. It worked for me

    0 讨论(0)
  • 2020-12-05 05:11

    This worked for me finally : RUN -> RUN CONFIGURATIONS -> DELETE THE RUN CONFIGURATION CLOSE ECLIPSE REOPEN ECLIPSE CREATE RUN CONFIGURATION AGAIN.

    Tadaaaa !! It works

    0 讨论(0)
  • 2020-12-05 05:14

    Move your file into a subdirectory called cont

    0 讨论(0)
  • 2020-12-05 05:15

    Renaming the main class should be enough (and easiest):
    - Go to your class and set cursor to your class name;
    - ALT + Shift + R and rename the class (build if not done automatically);
    - You should be able to run it now;
    - Rename the class to the old name if you want;

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