NetBeans中找不到主类 [英] No Main class found in 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.
推荐答案
- 在项目浏览器中右键单击您的项目
- 点击属性
- 点击运行
- 确保您的主类是您想成为的主类入口点。 (确保使用完全限定名称,即mypackage.MyClass)
- 单击确定。
- 运行项目:)
- Right click on your Project in the project explorer
- Click on properties
- Click on Run
- 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)
- Click OK.
- 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屋!