java - Error: Could not find or load main class -


i'm new java programming , doing project school. here's code i've written

public static void main(string args[]) import javax.swing.*; import java.awt.event.*; public class sleepcounter extends jframe {   private jpanel panel;   private jlabel messagelabel;   private jtextfield sleeptextfield;   private jtextfield sleepanswerfield;   private final int window_width = 310;   private final int window_height = 100;   public sleepcounter() {     settitle("sleep counter");     setsize(window_width, window_height);     setdefaultcloseoperation(jframe.exit_on_close);     buildpanel();     add(panel);     setvisible(true);   }   private void buildpanel() {     dailylabel = new jlabel("enter sleep " + "in hours");     hourtextfield = new jtextfield(10);     calcbutton = new jbutton("calculate");     calcbutton.addactionlistener(new calcbuttonlistener());     panel = new jpanel();     panel.add(dailylabel);     panel.add(sleeptextfield);     panel.add(calcbutton);     panel.add(sleepanswerfield);   }   private class calcbuttonlistener implements actionlistener {     public void actionperformer(actionevent e) {       string input;       int total;       input = sleeptextfield.gettext();       (int = 0; < 7; i++); {         input += total;       }       joptionpane.showmessagedialog(null, "the total amount of sleep " + (i + 1) + "days is" + total);       if (int > 7) {         double avg = (total / 7);         joptionpane.showmessagedialog(null, "the avg amount of sleep 7 days is" + avg);       }     }   } } 

when running error message saying:

error: not find or laod main class graduation project. 

i've done search of site , checked answers as know how. appreciate offer.

you have put main method outside class

 public class  yourclass  {   public static void main(string args[])    {      }   } 

place inside , remember cant put before these imports

import javax.swing.*; import java.awt.event.*; 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -