Netbeans - Error: Could not find or load main class

前端 未结 21 2066
时光说笑
时光说笑 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:28

    I found the following steps useful:

    1. Right-click on the project in the left toolbar.
    2. Hover over the 'Set Configuration' item.
    3. Click on 'Customize...'
    4. Click on 'Browse...' by the 'Main Class:' item.
    5. Select the correct class.
    6. Click 'Select Main Class'.
    7. Click 'OK'.

    My problem was that, apparently, my package name was being listed twice. Selecting the class using the dialog changed 'aclass.MainClass' to just 'MainClass'.

    Hope this helps,

    -HewwoCraziness

    Edit: This is expanding on Mary Martinez's answer.

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

    This condition happens to me every 6-months or so. I think it happens when closing NetBeans under very low memory conditions. I discovered that it could be easily corrected by (1) Rename your project, including its folder name using right-click on project explorer's project name---I put a simple suffix on the original name ("_damaged"). (2) Try BUILD. If that is successful, which it is for me, give three cheers. (3) Repeat step (1) to restore the original project name. BUILD and RUN should start without trouble. I guess that the 'rename the project and folder' process causes a special rediscovery of the applications main location.

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

    try this it work out for me perfectly go to project and right click on your java file at the right corner, go to properties, go to run, go to browse, and then select Main class. now you can run your program again.

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