[英]Netbeans error when trying to run java project
I am getting an error when trying to run my code in Java. 尝试在Java中运行代码时出现错误。 I am trying to run an output to a file where the user uses dialog boxes to input name, pay rate, and hours worked.
我正在尝试将输出运行到用户在其中使用对话框输入名称,工资率和工作时间的文件中。
This is the code I have: 这是我的代码:
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"));
}
}
But I get this error when trying to run the code: 但是在尝试运行代码时出现此错误:
Error: Could not find or load main class output.to.a.file.broc.east.OutputToAFileBrocEast
Java Result: 1
I am using Netbeans 7.4
. 我正在使用
Netbeans 7.4
。 and I have already attempted to delete the netbeans cache. 并且我已经尝试删除netbeans缓存。
If you build a jar, open it with 7zip or so, and you should find: 如果您创建一个罐子,请用7zip左右的罐子打开它,然后您会发现:
/output/to/a/file/broc/east/OutputToAFileBrocEast.class
The same when the same holds without jar: in the dist or target folder under classes. 不带jar的情况相同:位于dist或target文件夹下的类。
Maybe you have an extra directory or such. 也许您有一个额外的目录等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.