This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes problem in executing swing application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "problem in executing swing application" Watch "problem in executing swing application" New topic
Author

problem in executing swing application

Rituparna Duttagupta
Ranch Hand

Joined: Feb 08, 2011
Posts: 55

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??


With regards,
rituparna
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
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

Joined: Oct 13, 2005
Posts: 38033
    
  22
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

Joined: Oct 24, 2010
Posts: 557
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.


Learning Java using Eclipse on OpenSUSE 11.2
Linux user#: 501795
Rituparna Duttagupta
Ranch Hand

Joined: Feb 08, 2011
Posts: 55

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

Joined: Oct 13, 2005
Posts: 38033
    
  22
I think you are going to have to post the class you are trying to run, please.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
. . . 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.
 
Consider Paul's rocket mass heater.
 
subject: problem in executing swing application
 
Similar Threads
runtime error
Database programming using swing in browser
J9 and Swing
J9 and Swing libraries
Running the java program