Netbeans - class does not have a main method

后端 未结 12 2629
别跟我提以往
别跟我提以往 2020-12-06 14:28

My program is just a simple System.out.println(\"\"); But netbeans cannot find the main method. Is netbeans 6.7.1 conflict with WIN7? Any possible error?

12条回答
  •  温柔的废话
    2020-12-06 15:17

    My situation was different I believe because non of the above solutions di work for me. Let me share my situation.

    1. I am importing an existing project (NewProject->Java->Import Existing Projects)
    2. I name the project to xyz. The 'main' function exists in Main.class.
    3. I try to run the code I modified in the main function but the error pops out. I tried the shift_f6, specifically rebuild. Nothing works.

      Solution: I took the project properties and saw the 'Source Package Folder' mappings in the Sources branch was blank. I mapped it and voila it worked.

    Now anyone might think that was very silly of me. Although I am new to Java and Netbeans this is not the first time I am importing sample projects and I saw all of them had the properties similar. The only difference I saw was that the main class was not having the name as the project which I believe is a java convention. I am using JDK7u51 (latest till date), is it causing the issue? I have no idea. But I am happy the project is running fine now.

提交回复
热议问题