aspose file tools*
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 Spring in Action this week in the Spring 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: 3164
    
  47

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

Ps - Indenting the code properly makes the life easy.


Author of ExamLab ExamLab - a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like? -- Home -- Twitter -- How to Ask a Question
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11406
    
  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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Error in program