This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Error in program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error in program" Watch "Error in program" New topic
Author

Error in program

jose chiramal
Ranch Hand

Joined: Feb 12, 2010
Posts: 266
it gives me an error : java.lang.NoSuchMethodError: main
Exception in thread "main" . Anything wrong ?

Edited again: Please use code tags only for the code, not expository text.
Peter Taucher
Ranch Hand

Joined: Nov 18, 2006
Posts: 174
First of all: What kind of difficulties / error are we talking about. Is it a compiler error, or an error at runtime?
Second: Use code tags
Third: Check your blocks / braces. I think there's one closing bracket missing.

// Edit. OK, forget about the code tags ; - )


Censorship is the younger of two shameful sisters, the older one bears the name inquisition.
-- Johann Nepomuk Nestroy
W. Joe Smith
Ranch Hand

Joined: Feb 10, 2009
Posts: 710
You have your main method inside of your demoproc() method. I'm not sure you can do that.


SCJA
When I die, I want people to look at me and say "Yeah, he might have been crazy, but that was one zarkin frood that knew where his towel was."
Devaka Cooray
ExamLab Creator
Saloon Keeper

Joined: Jul 29, 2008
Posts: 3017
    
  35

I'm not sure you can do that.
Yep, you cannot.

Ps - Indenting the code properly makes the life easy.


Founder of ExamLab and Systemup
See how I can help you to become an awesome programmer
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11153
    
  16

here is your code properly formatted:


From that, it's easy to see you have a method (main) defined inside the demoproc method. You can't do that. Methods cannot be nested inside each other in java.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jim Hoglund
Ranch Hand

Joined: Jan 09, 2008
Posts: 525
It is well worth the effort to pay attention to proper indenting.
If you do, this kind of problem just does not happen.

Jim ... ...


BEE MBA PMP SCJP-6
 
jQuery in Action, 2nd edition
 
subject: Error in program
 
Similar Threads
Understanding Exception handling
RuntimeException v/s IllgealAccessException ?
Is Throwble a checked Exception
Throw - what's the point??
Exception declaration