[英]Why am I getting “Could not find or load main class …” error in NetBeans?
I am using netbeans on windows 7. I have created my main class in the creation of the program. 我在Windows 7上使用netbeans。我在创建程序时创建了我的主类。 I have been following a tutorial but for some reason I can never get it to populate the form.
我一直在学习教程,但由于某种原因,我无法获得它来填写表格。 What am I missing here?
我在这里想念什么?
package inventorygui;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.*;
public class InventoryGUI extends JFrame {
public static void main(String[] args) {
new InventoryGUI();
}
public InventoryGUI() {
this.setSize(400, 400);
Toolkit tk = Toolkit.getDefaultToolkit();
Dimension dim = tk.getScreenSize();
int xPos = (dim.width / 2) - (this.getWidth() / 2);
int yPos = (dim.height / 2) - (this.getHeight() / 2);
this.setLocation(xPos, yPos);
this.setResizable(false);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("Inventory Program");
JPanel thePanel = new JPanel();
JLabel label1 = new JLabel("Inventory Program Below");
thePanel.add(label1);
this.add(thePanel);
this.setVisible(true);
}
}
I tried compile it , it works fine no errors . 我尝试编译它,它工作正常,没有错误。
Notes : Be sure name of project as the public class ,also the name of package should be the same of package that you have . 注意:请确保项目名称为公共类,并且程序包的名称应与您拥有的程序包相同。 Try loading netbeans with another Jave SE version .
尝试使用另一个Jave SE版本加载netbeans。 Try loading it with Java SE 6.20 even its old, but works fine for netbeans on win7.
尝试使用Java SE 6.20甚至旧版本加载它,但是对于win7上的netbeans来说可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.