简体   繁体   English

为什么在NetBeans中出现“无法找到或加载主类……”错误?

[英]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.

相关问题 为什么我找不到或加载主类错误? - Why am I getting could not find or load main class error? 在Eclipse中,为什么会出现错误“错误:找不到或加载主类Coordinator.java”? - In Eclipse, why am I getting the error “Error: Could not find or load main class Coordinator.java”? Netbeans错误:找不到或加载主类 - Netbeans Error: Could not find or load main class Netbeans - 错误:无法找到或加载主类 - Netbeans - Error: Could not find or load main class 我一直收到错误消息“找不到或加载主类gradebooktest.GradeBookTest”,我不确定为什么 - I keep getting an error saying “Could not find or load main class gradebooktest.GradeBookTest” I am not sure why Java我在cdm提示符Windows 7中收到所有内容的“错误:无法找到或加载主类” - Java I am getting an “Error: Could not find or load main class” for everything in cdm prompt Windows 7 遇到错误-无法在NetBeans中找到或加载主类makeachange.Main - Getting Error - Could not find or load main class makingachange.Main in NetBeans 我不断收到错误消息:无法找到或加载主类,无法找出原因? - I keep getting Error: Could not find or load main class and cant figure out why? Netbeans 错误:无法找到或加载主类(再次) - Netbeans Error: Could not find or load main class (again) Java 错误:找不到或无法加载主 class - Netbeans Z581D6381F3F35E4F9D77201AC4 - Java error: Could not find or load main class - Netbeans IDE
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM