Search code examples
javanetbeansjava-6

could not load main class netbeans


public class Sequence {

    public static void main(String[] args) {
        int limit=20;
        int sum=0;
        int a=0;
        int b=1;

        while(sum<limit)
        {
            sum=a+b;
            a=b;
            b=sum;
        }
    }
}

My Netbeans was working fine when I was using jdk 1.8.0.65 earlier but due do some reason I lost my data, I installed jdk 1.8.0.73 then and now my every program on Netbeans shows this error:

run: Error: Could not find or load main class sequence.Sequence C:\Users\owais\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1 BUILD FAILED (total time: 0 seconds)

I googled the problem and updated the netbeans_jdk path in netbeans.config file but still it does not work. I am new to programming I would really appreciate some help.


Solution

  • Actuall, when you click the "Run" button on top of the netbeans window, it only run the application's main class . but this Sequence class is not the main class of the project most probably. for this case to run this class you have to right click on Sequence class editor and select Run or Run as menu. Then this class will be executed on separate console, I hope this will work ..