简体   繁体   中英

Netbeans Error: Could not find or load main class

When I run the below code, I get the error that Could not find or load main class. I have removed the package and created it again. But the error is still exist. I did some methods to fix it such as right clicking on package name -> properties -> run option to change the main method but there is nothing. But if I create another package name and write this code in it, the program work.

package craps;

public class Craps {


public static void main(String[] args) {
    int number = 10;
    System.out.println(number);
}   

}

Your code is not having any errors I don't know what is happening in Netbeans .I have been using this for years and living with this kind of errors. perhaps you get this when netbeans running out of memory and that particular moment you are editing this file.

My workaround for this kind of errors are
1.Do some dummy editing in that file like commenting some empty line // and save All and recompile it
2.Close and open this project (Sometimes work)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM