•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 428,065 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,482 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 623 | Replies: 14
![]() |
•
•
Join Date: May 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
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
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
•
•
Join Date: Oct 2006
Location: the Netherlands
Posts: 1,780
Reputation:
Rep Power: 11
Solved Threads: 185
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,467
Reputation:
Rep Power: 11
Solved Threads: 296
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
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
•
•
Join Date: May 2008
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
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?
•
•
Join Date: Dec 2004
Location: London or Slovakia
Posts: 2,467
Reputation:
Rep Power: 11
Solved Threads: 296
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
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
Publilius Syrus
(~100 BC)
If we helped you to solve your problem, answered your question please mark your post as SOLVED.
For starters, this is not a valid method body This is
public void init()
public void init() {
// stuff
} Last edited by Ezzaral : May 15th, 2008 at 9:32 am.
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 199
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.
.
"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.
.
Last edited by jephthah : May 16th, 2008 at 4:42 pm.
Why so serious?
•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation:
Rep Power: 18
Solved Threads: 199
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...
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Java Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- FRONTECH tv tuner card - stuck lost - urgent help needed (PCI and Add-In Cards)
- Urgent help is needed SQL datatypes (Database Design)
- Urgent help needed regarding executing Scripts in AJAX response (JavaScript / DHTML / AJAX)
- URGENT HELP NEEDED - critically important...!!! (Windows NT / 2000 / XP / 2003)
- extreme urgent help needed (Geeks' Lounge)
- Urgent help needed (Database Design)
- Urgent help needed.!!.Please (C)
- URGENT Help Needed With TicTacToe Application Source Code!!! (Java)
Other Threads in the Java Forum
- Previous Thread: Read in from a text file randomly
- Next Thread: Help! JApplet -> JFrames



Linear Mode