在 NetBeans 中找不到 Main 类 [英] No Main class found in NetBeans

查看:49
本文介绍了在 NetBeans 中找不到 Main 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为我的课程编写编程作业.我正在使用 NetBeans.我完成了我的项目,效果很好.当我尝试运行它时,我收到一条消息,显示找不到主类".下面是一些主要的代码:

I have been working on an assignment for my class in programming. I am working with NetBeans. I finished my project and it worked fine. I am getting a message that says "No main class found" when I try to run it. Here is some of the code with the main:

package luisrp3;
import java.io.FileNotFoundException;
import java.io.PrintStream;

public class LuisRp3 {

public static void main(String[] args) throws FileNotFoundException  {

    java.io.File newFile = new java.io.File("LuisRamosp4.txt");

    if (newFile.exists()) {
        newFile.delete();
    }

    System.setOut(new PrintStream(newFile));

    Guitar guitar = new Guitar(); 

我之前发布过这个,但有几个问题.我已经修复了其他的,现在只剩下这个了.任何建议将不胜感激.

I posted this before but had a couple issues. i have fixed the others and now have just this one remaining. Any advice will be greatly appreciated.

推荐答案

  1. 在项目资源管理器中右键单击您的项目
  2. 点击属性
  3. 点击运行
  4. 确保您的主类是您想要作为入口点的类.(确保使用完全限定名称,即 mypackage.MyClass)
  5. 点击确定.
  6. 运行项目:)

如果您只想运行文件,请在包资源管理器中右键单击该类,然后单击运行文件,或 (Alt + R, F) 或 (Shift + F6)

If you just want to run the file, right click on the class from the package explorer, and click Run File, or (Alt + R, F), or (Shift + F6)

这篇关于在 NetBeans 中找不到 Main 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆