error explanation

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Mar 2008
Posts: 4
Reputation: maelthra is an unknown quantity at this point 
Solved Threads: 0
maelthra maelthra is offline Offline
Newbie Poster

error explanation

 
0
  #1
Mar 26th, 2008
what does it mean when while trying to run a .class file I get "Exception in thread "main" java.lang..NoSuchMethodError: main"???
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Re: error explanation

 
0
  #2
Mar 27th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 4
Reputation: maelthra is an unknown quantity at this point 
Solved Threads: 0
maelthra maelthra is offline Offline
Newbie Poster

Re: error explanation

 
0
  #3
Mar 27th, 2008
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.
Attached Files
File Type: java JMath.java (3.0 KB, 4 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 224
Reputation: bugmenot is an unknown quantity at this point 
Solved Threads: 31
bugmenot bugmenot is offline Offline
Posting Whiz in Training

Re: error explanation

 
0
  #4
Mar 27th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Sep 2006
Posts: 84
Reputation: rinoa04 is on a distinguished road 
Solved Threads: 4
rinoa04's Avatar
rinoa04 rinoa04 is offline Offline
Junior Poster in Training

Re: error explanation

 
1
  #5
Mar 27th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 4
Reputation: maelthra is an unknown quantity at this point 
Solved Threads: 0
maelthra maelthra is offline Offline
Newbie Poster

Re: error explanation

 
0
  #6
Mar 27th, 2008
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
Attached Files
File Type: java Multiplication.java (782 Bytes, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: error explanation

 
0
  #7
Mar 27th, 2008
do you know any Java at all?
Those lines are utter nonsense in the light of the language specification.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 224
Reputation: bugmenot is an unknown quantity at this point 
Solved Threads: 31
bugmenot bugmenot is offline Offline
Posting Whiz in Training

Re: error explanation

 
0
  #8
Mar 27th, 2008
um.. so for starters, you know that you can only put code in methods? you can't have statements randomly outside methods
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 4
Reputation: maelthra is an unknown quantity at this point 
Solved Threads: 0
maelthra maelthra is offline Offline
Newbie Poster

Re: error explanation

 
0
  #9
Mar 27th, 2008
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.
Attached Files
File Type: java Multiplication.java (783 Bytes, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1
Reputation: mailmeatvishnu is an unknown quantity at this point 
Solved Threads: 0
mailmeatvishnu mailmeatvishnu is offline Offline
Newbie Poster

Re: error explanation

 
0
  #10
Mar 30th, 2008
check wether u had saved the name of file as a class which has got main method....remember it is case sensitive
Last edited by mailmeatvishnu; Mar 30th, 2008 at 8:06 am. Reason: gramaar
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 1048 | Replies: 9
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC