簡體   English   中英

Netbeans錯誤:找不到或加載主類

[英]Netbeans Error: Could not find or load main class

當我運行下面的代碼時,出現錯誤,找不到或加載main類。 我已經刪除了程序包並再次創建了它。 但是錯誤仍然存​​在。 我做了一些方法來解決它,例如右鍵單擊程序包name -> properties -> run選項以更改main方法,但沒有任何方法。 但是,如果我創建另一個程序包名稱並在其中編寫此代碼,則該程序可以正常工作。

package craps;

public class Craps {


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

}

您的代碼沒有任何錯誤,我不知道Netbeans中正在發生什么。我已經使用了多年,並且一直遇到這種錯誤。 當netbeans的內存不足,並且正在編輯該文件的那一刻,也許您會收到此消息。

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)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM