Why “Error: Could not find or load main class addstudent.AddStudent” is showing

前端 未结 3 1364
醉话见心
醉话见心 2021-01-24 11:29

I am developing a project using NetBeans IDE. I am new to javafx. I created a class \"AddStudent\" in a package named \"addstudent\". When I ran the class, I got \"Error: Could

相关标签:
3条回答
  • 2021-01-24 11:41

    In my case, the problem was the project path had some special (russian) chars, like

    C:\Dev\Папка\MyApp\
    

    Once moved to another folder, it worked:

    C:\Dev\Good one\MyApp\
    

    Also:

    • these characters are OK: äöü!@#$%^&_+-``~_',
    • these are not: №;
    0 讨论(0)
  • 2021-01-24 11:57

    I was getting the same error while running my javaFx program.

    And now I got the answer about how to fix it.

    • Create your javaFx project on netBeans
    • New Project-> JavaFx
    • Application-> Finish

    When you do this, you'll see a class with the same name as the name of the project.

    When you try to run that file you'll get this error:

    Error: Could not load or Find main class classname
    

    to fix this error, simply rightclick on your project and click run.

    Your project runs and you'll see something like, "say hello world". After that it will work fine.

    One more thing, when you try to run your project with webstart on netBeans it will not work!

    And it is possible to get an error like

    Error : javaFxApplication.jar could not Be deleted.
    

    to fix this open your task manager and go to Background Process look for Java() Binary file 32 bit, just end that task and you're back.

    0 讨论(0)
  • 2021-01-24 12:02

    I'm running your code and it works fine. What I did

    1. Created New -> JavaFx Main Class -> AdStudent -> Copy/Pasted your code

    2. Right click on Project -> Properties -> Run -> Browse Application Class -> Select class addstudent.AddStudent

    3. Clean and Build

    4. Run Project

    I have a feeling the first 2 are fine for you. You may just need to Clean and Build.

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