• Post Reply Bookmark Topic Watch Topic
  • New Topic

Error: <no main classes found>  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm reading a book titled 'Java - How to Program', by Dietel & Dietel. Great book! I have a question about some sample code.

In the book, this code snippet is supposed to popup a DialogBox, but I keep getting an error.


import javax.swing.JOptionPane;
public class Dialog1
{
public void main(String[] args)
{
JOptionPane.showMessageDialog( null, "Welcome\nto\nJava" );
}
}


When I hit F6, I get an error message that says <no main classes found>. The Main Class is right there. I copied it right from the book. Why does it think the Main Class is not found and what do I need to do to make this work?

Thanks.
 
Ranch Hand
Posts: 99
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main method has to be public, static and void.
 
Ry Shu
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I see.

Thanks everyone!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!