Re: Input/Output program Compiles but doesn't run
- From: "janicethorne via JavaKB.com" <u16040@uwe>
- Date: Thu, 30 Mar 2006 18:43:34 GMT
Carl wrote:
Can anyone help me with this error? I have included the code after the[quoted text clipped - 7 lines]
explaination.
everything I was supposed to, but I am a beginner and can't always tell if I
need more. Any help will be appreciated. thank you.
The java main method with the signature
public static void main(String[] args)
is special and will be used to start the application. You have not
declared this method, hence the "NoSuchMethodError: main" error; the
main method with this _exact_ signature cannot be found.
You have declared an instance method with the signature
main(String[] args).
Note that simply adding the static modifier to your main method will
not work as your main method references non static instance variables.
Hope that helps,
Carl.
Carl:
Thanks for your reply. Yes, I found that out when I added the static modifier
to the code and tried to compile it. I then declared my variables private and
static along with making the main method static. The only error I am getting
now is:
C:\Documents and Settings\JThorne\Desktop\Homework\Program81.java:74: non-
static variable this cannot be referenced from a static context
button = new ButtonHandler();
The button is in my main method. Why is this error occurring?
--
"The man who does not read good books has no advantage over the man who
cannot read them."
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-setup/200603/1
.
- Follow-Ups:
- References:
- Input/Output program Compiles but doesn't run
- From: janicethorne via JavaKB.com
- Re: Input/Output program Compiles but doesn't run
- From: Carl
- Input/Output program Compiles but doesn't run
- Prev by Date: Re: File IO -- Reading Config Files Easily
- Next by Date: Re: File IO -- Reading Config Files Easily
- Previous by thread: Re: Input/Output program Compiles but doesn't run
- Next by thread: Re: Input/Output program Compiles but doesn't run
- Index(es):