what does it mean when while trying to run a .class file I get "Exception in thread "main" java.lang..NoSuchMethodError: main"???

Most probably the .class file that you are trying to run is not a driver class where the main method is coded to call and run the coding.

Well I am using the file from another post here in the forums, I was playing around look for code to go through to better my understanding.

the file is attached below, it compiles fine but won't run, and I get the afore mentioned error.

it appears to be an applet. you usually have to embed the applet in an HTML page using applet tags and use a browser to run it

To run an applet, you will need an html file with this example coding:

<Html>
<Head>
<Title>Java Example</Title>
</Head>
<Body>
This is my page<br>
Below you see an applet<br>
<br>
<Applet Code="MyApplet.class" width=200 Height=100>
</Applet>
</Body>
</Html>

You must specify the .class file that you compile at the applet code tag. Use appletviewer command to run the html file on DOS.

commented: Very nice, concise explanation +1

okay I played with the code did something different, so that I don't have to use, html. but I am getting all of these errors file is attached. if anyone could help me I would be very happy... LOL


F:\Javawork\Multiplication\Multiplication.java:22: <identifier> expected
System.out.println("How much is "); int = Number1 (" TIMES "); int = Number2 (" ? ");
^
F:\Javawork\Multiplication\Multiplication.java:22: illegal start of type
System.out.println("How much is "); int = Number1 (" TIMES "); int = Number2 (" ? ");
^
F:\Javawork\Multiplication\Multiplication.java:22: <identifier> expected
System.out.println("How much is "); int = Number1 (" TIMES "); int = Number2 (" ? ");
^
F:\Javawork\Multiplication\Multiplication.java:22: <identifier> expected
System.out.println("How much is "); int = Number1 (" TIMES "); int = Number2 (" ? ");
^
F:\Javawork\Multiplication\Multiplication.java:23: <identifier> expected
UserAnswer = input.nextInt();
^
F:\Javawork\Multiplication\Multiplication.java:26: illegal start of type
if ( int = UserAnswer == int = ActualAnswer ) // if answer is correct
^
F:\Javawork\Multiplication\Multiplication.java:26: <identifier> expected
if ( int = UserAnswer == int = ActualAnswer ) // if answer is correct
^
F:\Javawork\Multiplication\Multiplication.java:26: ';' expected
if ( int = UserAnswer == int = ActualAnswer ) // if answer is correct
^
F:\Javawork\Multiplication\Multiplication.java:26: illegal start of type
if ( int = UserAnswer == int = ActualAnswer ) // if answer is correct
^
F:\Javawork\Multiplication\Multiplication.java:26: <identifier> expected
if ( int = UserAnswer == int = ActualAnswer ) // if answer is correct
^
F:\Javawork\Multiplication\Multiplication.java:26: ';' expected
if ( int = UserAnswer == int = ActualAnswer ) // if answer is correct
^
F:\Javawork\Multiplication\Multiplication.java:30: illegal start of type
if ( int = UserAnswer != int = ActualAnswer ) // if answer is not correct
^
F:\Javawork\Multiplication\Multiplication.java:30: <identifier> expected
if ( int = UserAnswer != int = ActualAnswer ) // if answer is not correct
^
F:\Javawork\Multiplication\Multiplication.java:30: ';' expected
if ( int = UserAnswer != int = ActualAnswer ) // if answer is not correct
^
F:\Javawork\Multiplication\Multiplication.java:30: illegal start of type
if ( int = UserAnswer != int = ActualAnswer ) // if answer is not correct
^
F:\Javawork\Multiplication\Multiplication.java:30: <identifier> expected
if ( int = UserAnswer != int = ActualAnswer ) // if answer is not correct
^
F:\Javawork\Multiplication\Multiplication.java:30: ';' expected
if ( int = UserAnswer != int = ActualAnswer ) // if answer is not correct
^
17 errors

Tool completed with exit code 1

do you know any Java at all?
Those lines are utter nonsense in the light of the language specification.

um.. so for starters, you know that you can only put code in methods? you can't have statements randomly outside methods

okay this program is almost halfway done, right now I have no errors and the file runs fine, except I need it to ask another random question if the user gets the right answer, or back to the same question if the user gets it wrong. I am thinking of using if-else or while statements, but I am not sure how to form them. attached is the current file as is.

check wether u had saved the name of file as a class which has got main method....remember it is case sensitive