No Main class found in NetBeans

前端 未结 16 2474
时光说笑
时光说笑 2020-11-30 08:32

I have been working on an assignment for my class in programming. I am working with NetBeans. I finished my project and it worked fine. I am getting a message that says \"No

16条回答
  •  情歌与酒
    2020-11-30 09:07

    When creating a new project - Maven - Java application in Netbeans the IDE is not recognizing the Main class on 1st class entry. (in Step 8 below we see no classes).

    When first a generic class is created and then the Main class is created Netbeans is registering the Main class and the app could be run and debugged.

    Steps that worked for me:

    1. Create new project - Maven - Java application (project created: mytest; package created: com.me.test)
    2. Right-click package: com.me.test
    3. New > Java Class > Named it 'Whatever' you want
    4. Right-click package: com.me.test
    5. New > Java Main Class > named it: 'Main' (must be 'Main')
    6. Right click on Project mytest
    7. Click on Properties
    8. Click on Run > next to 'Main Class' text box: > Browse
    9. You should see: com.me.test.Main
    10. Select it and click "Select Main Class"

    Hope this works for others as well.

提交回复
热议问题