2014-03-29 57 views
0

當我運行下面的代碼時,出現無法找到或加載main類的錯誤。我已經刪除了包並重新創建了它。但錯誤仍然存​​在。我做了一些方法來修復它,比如右鍵單擊包name -> properties -> run選項來更改main方法,但沒有任何內容。但是,如果我創建另一個軟件包名稱並在其中編寫該代碼,該程序就可以工作。Netbeans錯誤:無法找到或加載主類

package craps; 

public class Craps { 


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

}

+0

這個問題在這個線程中提到:http://stackoverflow.com/questions/20034377/netbeans-error-could-not-find-or-load-main-class?rq=1看看。 – Alegria

+0

通過屬性更改主類後,嘗試清理並構建。通常這需要完成。 –

+0

@Alegria我之前查看過該主題。它不適合我。 – User

回答

0

您的代碼沒有任何錯誤 我不知道什麼是在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) 
相關問題