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

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

问题描述

我一直在为我的班级编程工作。我正在使用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. 运行项目:)

  1. Right click on your Project in the project explorer
  2. Click on properties
  3. Click on Run
  4. Make sure your Main Class is the one you want to be the entry point. (Make sure to use the fully qualified name i.e. mypackage.MyClass)
  5. Click OK.
  6. Run Project :)

如果您只想运行该文件,请右键单击包浏览器中的类,然后单击运行文件或( 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中找不到主类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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