DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Urgent!! help needed please please! (http://www.daniweb.com/forums/thread124343.html)

mattcrow May 15th, 2008 6:56 am
Urgent!! help needed please please!
 
Hi everyone

I need to hand in this assignment today :(
Im trying to read from a file and read it onto the screen, my code keeps showing up an error saying 'java.lang.NoSuchMethodError: Main'

Here is my code:

import java.io.*;
import java.awt.*;
import java.applet.*;

public class Empty_3 extends Applet {

TextArea ta = new TextArea();

public void init()
public static void main(String args[])
{
setLayout(new BorderLayout());
add(ta, BorderLayout.CENTER);
try {
InputStream in =
getClass().getResourceAsStream("test1.txt");
InputStreamReader isr =
new InputStreamReader(in);
BufferedReader br =
new BufferedReader(isr);
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
String line;
while ((line = br.readLine()) != null) {
pw.println(line);
}
ta.setText(sw.toString());
} catch (IOException io) {
ta.setText("Ooops");
}
}
}



Can anyone help me please?

Thankyou

Matt

niek_e May 15th, 2008 7:32 am
Re: Urgent!! help needed please please!
 
[edit] Nonsense...

peter_budo May 15th, 2008 7:36 am
Re: Urgent!! help needed please please!
 
If you paid more attention in your classes you would know that Applet DO NOT USE "main" class call. For more info follow Sun Applet tutorials here

mattcrow May 15th, 2008 7:46 am
Re: Urgent!! help needed please please!
 
well thats what i did at first but it came up with this error?

'missing method body, or declare abstract'
under the public void init()

so do you know where to go from there?

mattcrow May 15th, 2008 7:48 am
Re: Urgent!! help needed please please!
 
Quote:

Originally Posted by peter_budo (Post 607355)
If you paid more attention in your classes you would know that Applet DO NOT USE "main" class call. For more info follow Sun Applet tutorials here




well thats what i did at first but it came up with this error?

'missing method body, or declare abstract'
under the public void init()

so do you know where to go from there?

peter_budo May 15th, 2008 7:56 am
Re: Urgent!! help needed please please!
 
Well drop the code as you had before or how it should be based on the assistance of the link (please do not forget to use code tags, just simply click on the hash sign "#" in advanced editing options, "Go Advanced" will get you there) and some short explanation of you trying to do would be nice

Ezzaral May 15th, 2008 9:31 am
Re: Urgent!! help needed please please!
 
For starters, this is not a valid method body
public void init() 
This is
public void init() {
    // stuff
}

jwenting May 15th, 2008 12:56 pm
Re: Urgent!! help needed please please!
 
I don't see the urgency here. Haven't felt the need to use an applet for a decade.

jephthah May 16th, 2008 4:41 pm
Re: Urgent!! help needed please please!
 
everything is urgent, it seems. people need to start posting their questions with subject headings like:

"Help Help!! Life or Death Problem Here!!!"

or maybe

"OMG MY ASS IS ON FIRE AND MY HEAD IS A-CATCHIN', SUMBODY PLS ANSWER MY Q!!!"

otherwise, im gonna get bogged down trying to answer all these merely "urgent" questions.



.

jwenting May 17th, 2008 1:33 am
Re: Urgent!! help needed please please!
 
yah. It's no different in customer support. Customers flag every single issue as critical, with the inevitable result that we stop looking at that flag and determine ourselves what's important...


All times are GMT -4. The time now is 5:13 pm.

Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC