2014-04-01 168 views
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緩存。

+0

看到[這個問題](http://stackoverflow.com/questions/18814602/error-could-not-find-or-load-main-class-netbeans-and-java) – Reimeus

+0

檢查你的java類的文件名。它是OutputToAFileBrocEast.java? –

+0

@DonChakkappan我剛剛檢查,是的它是OutputToAFileBrocEast.java – user3485794

回答

0

如果你建立一個罐子,用7zip的左右打開它,你會發現:

/output/to/a/file/broc/east/OutputToAFileBrocEast.class 

時同樣適用,而不罐子裏一樣的:在classes下的距離或目標文件夾。

也許你有一個額外的目錄或諸如此類。

相關問題