Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Error in program

 
jose chiramal
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ; - )
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You have your main method inside of your demoproc() method. I'm not sure you can do that.
 
Devaka Cooray
ExamLab Creator
Marshal
Pie
Posts: 4252
227
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure you can do that.
Yep, you cannot.

Ps - Indenting the code properly makes the life easy.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jim Hoglund
Ranch Hand
Posts: 525
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is well worth the effort to pay attention to proper indenting.
If you do, this kind of problem just does not happen.

Jim ... ...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic