0
嘗試在Java中運行我的代碼時出現錯誤。我正在嘗試將輸出運行到用戶使用對話框輸入姓名,工資率和工作時間的文件。嘗試運行java項目時出現Netbeans錯誤
這是我的代碼:
package output.to.a.file.broc.east;
import javax.swing.JOptionPane;
public class OutputToAFileBrocEast
{
public static void main(String[] args)
{
OutputFile payFile;
payFile = new OutputFile ("payroll.txt");
String name;
String rate;
String hours;
String answer;
do
{
int number1;
int number2;
name = JOptionPane.showInputDialog("Enter first and last name: ");
rate = JOptionPane.showInputDialog("Enter hourly rate: ");
hours = JOptionPane.showInputDialog("Enter hours for previous week: ");
number1 = Integer.parseInt (rate);
number2 = Integer.parseInt (hours);
payFile.writeWord(name);
payFile.writeWord(rate);
payFile.writeWord(hours);
payFile.writeEOL();
answer = JOptionPane.showInputDialog("Do you have another employee? [y/n");
}
while (answer.equalsIgnoreCase ("yes"));
}
}
但我在嘗試運行代碼時,此錯誤:
Error: Could not find or load main class output.to.a.file.broc.east.OutputToAFileBrocEast
Java Result: 1
我使用Netbeans 7.4
。我已經試圖刪除netbeans緩存。
看到[這個問題](http://stackoverflow.com/questions/18814602/error-could-not-find-or-load-main-class-netbeans-and-java) – Reimeus
檢查你的java類的文件名。它是OutputToAFileBrocEast.java? –
@DonChakkappan我剛剛檢查,是的它是OutputToAFileBrocEast.java – user3485794