File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 36453
    
  15
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: 36453
    
  15
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: 36453
    
  15
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: 36453
    
  15
. . . 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in executing swing application
 
Similar Threads
J9 and Swing
Running the java program
J9 and Swing libraries
Database programming using swing in browser
runtime error