This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund 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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2691
    
    3

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

Ps - Indenting the code properly makes the life easy.


Author of ExamLab (Download) - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9948
    
    6

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.


Never ascribe to malice that which can be adequately explained by stupidity.
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
 
Similar Threads
Exception declaration
Throw - what's the point??
Understanding Exception handling
Is Throwble a checked Exception
RuntimeException v/s IllgealAccessException ?