Results 1 to 7 of 7
Thread: Applet Main Thread Error
- 09-14-2010, 04:24 AM #1
Member
- Join Date
- Apr 2009
- Posts
- 84
- Rep Power
- 0
Applet Main Thread Error
Hey guyz , ive got below program :
However , as i try to run , i got below error :Java Code:import java.awt.Graphics; import java.awt.Image; public class BJ1 extends java.applet.Applet { Image mypic; public void init() { mypic = getImage(getCodeBase(), "C01.jpg"); } public void paint(Graphics screen) { int iWidth =71 ;//71 int iWidth =mypic.getWidth(this); int iHeight=96; //96 int iHeight=mypic.getHeight(this); int xPos = 10; screen.drawImage(mypic, xPos,10, this); } }
java.lang.NoSuchMethodError: main
Exception in thread "main"
what does that mean n how can i solve this problem ?
tnx :)
- 09-14-2010, 04:53 AM #2
How are you trying to execute your applet? The error message says you were trying to use the java command. Applets are executed in a browser by coding an <APPLET tag in some html and having the browser read the html page and then the class file.
If you want to execute a class with the java program you need to have a main(String[] args) method in it.
- 09-14-2010, 05:05 AM #3
Member
- Join Date
- Apr 2009
- Posts
- 84
- Rep Power
- 0
how can i implement the main thread into my program so it can run on Java ?
- 09-14-2010, 01:31 PM #4
Member
- Join Date
- Apr 2009
- Posts
- 84
- Rep Power
- 0
Anybody can help ?
- 09-14-2010, 02:08 PM #5
Do you want it to run as an applet or as an application?
An applet runs from an html page.
To make a desktop application out of your code requires a major rewrite.
- 09-14-2010, 06:47 PM #6
Member
- Join Date
- Apr 2009
- Posts
- 84
- Rep Power
- 0
i need to run it as desktop applet , could u help me to run it ?! tnx
- 09-14-2010, 07:12 PM #7
Do you want an applet or an application?i need to run it as desktop applet
For an applet, write an html page with the applet tag.
First it needs a GUI. Extend JFrame instead of appletTo make a desktop application out of your code requires a major rewrite.
Add a constructor to fill the frame with the components you want (see below).
Move the code from the init method to the constructor
Add a main(String[] args) method that calls the constructor.
Move/change the paint method to be the paintComponent method in a JPanel.
Add that panel to the frame.
Similar Threads
-
Exception in thread "main" java.lang.Error: Unresolved compilation problem
By jcen in forum New To JavaReplies: 2Last Post: 11-06-2011, 04:40 PM -
Question about error "Exception in thread "main" java.lang.NoSuchMethodError: main
By ferdzz in forum New To JavaReplies: 5Last Post: 06-22-2010, 03:51 PM -
getting an error Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/hu
By Hussain Ali in forum EclipseReplies: 8Last Post: 02-23-2010, 12:22 PM -
ERROR: Exception in thread "main" java.lang.NoSuchMethodError: main
By barney in forum New To JavaReplies: 1Last Post: 08-07-2007, 07:10 AM -
Error: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
By romina in forum New To JavaReplies: 1Last Post: 07-25-2007, 10:55 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks