尝试运行java项目时出现Netbeans错误

时间:2014-04-01 15:31:40

标签: java netbeans

尝试在Java中运行代码时出错。我正在尝试将输出运行到一个文件,用户使用该文件输入名称,工资率和工作小时数。

这是我的代码:

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缓存。

1 个答案:

答案 0 :(得分:0)

如果您构建一个jar,请使用7zip左右打开它,您应该找到:

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

同样在没有jar的情况下保持:在类下的dist或target文件夹中。

也许您有一个额外的目录等。