Netbeans - Error: Could not find or load main class

前端 未结 21 2068
时光说笑
时光说笑 2020-11-28 16:01

So I\'m making a java application in Neatbeans 7.4, been working at it for a while, everything was fine, running the project worked fine, but now when I hit run project, I g

相关标签:
21条回答
  • 2020-11-28 16:23

    I faced the similar issue with Netbeans 10 and JDK 1.8. I was not able to choose the right class to launch the project When I compile or run the project, it shows me the Class name as "initializing view, please wait ...", I could not select the class name. The issue was resolved with the NetBeans11.3, I am able to choose the correct Class file without any other changes, and the project is launched without any issues.

    0 讨论(0)
  • 2020-11-28 16:25

    You can :

    • RightClick on project node and go to Set configuration
    • Select the main class for your application.
    • Then clean and build.

    Even if the above steps don't work for you then then delete the Netbeans cache by deleting the (index) folder

    User\.netbeans\SOME_NUMBER_reflecting_your_version\var\cache\index\
    
    0 讨论(0)
  • 2020-11-28 16:25

    I had the same problem, I had the package and class named the same. I renamed the class, then clean and build. Then I set the main class in the "run" under the properties of the project. I works now.

    0 讨论(0)
  • 2020-11-28 16:26

    if you are on window os, then try to start NetBeans via administrative mode. right click on NetBeans icon and "Run as Administrative".

    0 讨论(0)
  • 2020-11-28 16:27

    I just ran into this problem. I was running my source from the command line and kept getting the same error. It turns out that I needed to remove the package name from my source code and then the command line compiler was happy.

    The solutions above didn't work for me so maybe this will work for someone else with a similar problem.

    0 讨论(0)
  • 2020-11-28 16:28

    I had the same issue once. The problem was not in the code. The cause was... renaming the project folder to some other non supporting name. My project name was "MobStick" and I renamed it to "MobStick - May 26, 2014 04:00PM". Renaming it back to normal solved my problem.

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