• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in executing swing application

 
Rituparna Duttagupta
Ranch Hand
Posts: 55
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends, i'm facing a strange problem while ruuning a swing applet program. my program is compiling alright, but wenevr i mtrying to run it from command prompt, it's showing the following exception::

"Exception in thread"main" java.lang.NoSuchMethodError: main"

even in netbeans ide it's showing the same thing?
where m i going wrong??
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need a main method in the class you are invoking from the command line. It must have a certain heading format.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your spelling is all over the place. If you spell your Java™ code as you spell your postings, you might have introduced an error into your code which can cause such an Exception.
 
Greg Brannon
Bartender
Posts: 563
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I assume you're trying to run the compiled applet code using a command line command:

> java applet

( > is the command line prompt, not something you'd type )

where "applet.class" is the name of your compiled applet.java source file.

Applets are viewed/run from within an HTML file. There are several places on the internet that give you advice on how to construct an HTML file to run an Applet from the command line or use command line Applet viewers. Since I don't know your particular environment setup, I won't recommend a particular one of those.

Netbeans should have the ability to run your source code as an Applet. If you right click on the source file, do you get a context menu with "Run as . . ." or "Run as Applet" as a selection? If so, pursue that to use Netbeans' internal Applet viewer.

Come back if you need more help.
 
Rituparna Duttagupta
Ranch Hand
Posts: 55
Firefox Browser Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks foryour information, but no, i don't make spelling alteration while coding.
and i've checked everything, even after including the main method the applet is not showing.
actually, the last 3 years i was into jsp, servlet,session, stateful and entity beans.
i think i am terribly faulting somewhere, since i was detached from swing/applet forlong period of time.
:-)
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are going to have to post the class you are trying to run, please.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and sorry, I missed the bit about applets. You usually open applets from an html file, which you open with a browser, as Greg Brannon has already told you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic