AW: beginner's question
- From: "wildsaug" <w.frankenberg@xxxxxx>
- Date: sun, 1 jul 2007 17:59:37 +0200
Hi,
the main Methode must be :
public static void main (String[] args) { any code }
greetings
TideRider:
Eclipse can either link to Javadocs on the internet or to downloadedlocal copies. For either,
you go into the Java Build Path properties for that library (startingwith rt.jar!) and set the Javadoc
location. For a Java 5 rt.jar, you can set the Javadoc location tohttp://java.sun.com/j2se/1.5.0/docs/api/
.into a location on your
You can also download the documentation from sun.java,com and unzip it
computer. I do that for the APIs I use most, because I sometimes workon code when I don't
have Internet connectivity.news:451248fa@xxxxxxxxxxxx
--
TideRider
"Jacky Luk" <jl@xxxxxxxxxx> wrote in message
|¼¶¼g©ó¶l¥ó·s»D:Xns984485A746F71vaj4088ianshef@xxxxxxxxxxxxxxxxxx
| "Ian Shef" <invalid@xxxxxxxxxxxxx>
| > "Jacky Luk" <jl@xxxxxxxxxx> wrote in news:45116ca0$1@xxxxxxxxx:String,
| >
| >> import java.awt.Graphics;
| >>
| >> public class printtest extends java.applet.Applet
| >> {
| >> public void init()
| >> {
| >> }
| >>
| >> public void paint (Graphics g)
| >> {
| >> g.drawString ("Hello from java!", 60, 30);
| >> }
| >>
| >> public static void main (String args)
| >> {
| >>
| >> }
| >> }
| >> ===============================
| >> java.lang.NoSuchMethodError: main
| >> Exception in thread "main"
| >>
| >> What happened?
| >> Thanks
| >> Jack
| >
| > 1)
| > The main method must be declared public and static. Good!
| > It must not return any value. Good!
| > It must accept a String array as a parameter. Oops! You have a
| > not"java".
| > a String array.
| >
| > The method declaration must look like the following:
| >
| > public static void main(String args[])
| >
| > The above has been partially copied out of the javadocs for
| > Get the javadocs and use them. They are your friend.method, it
| >
| > 2)
| > Note for the future: When java tells you that it cannot find a
| > is vital to remeber that the method must match both in name andin
| > signature. Method definitions don't match method calls unless amethod of
| > the correct name can be found that has a parameter list that alsomatches
| > the one used for the call.might
| >
| > 3)
| > If I saw an experienced java programmer writing this program, I
| > figure that they are writing a mixed application/applet orotherwise doing
| > something clever -- maybe providing a way to test an appletwithout
| > requiring an applet viewer. However, when someone who describesthemself
| > as a beginner writes this way, I get concerned.to be
| >
| > Your class extends Applet, indicating that you intend this program
| > anintend
| > Applet. However, you have a method "main", indicating that you
| > thisit,
| > program to be an application. Furthermore, you used "java" to run
| > again indicating that your intent was for an application.please
| >
| > If your intent was cleverness or a mixed application/applet,
| > forgivewhether
| > me. Otherwise, you need to re-think what you are doing and decide
| > you want an application or an applet. Then rethink your design.couldn't find
| >
| > Best wishes!
| >
| >
| >
| > --
| > Ian Shef 805/F6 * These are my personal opinions
| > Raytheon Company * and not those of my employer.
| > PO Box 11337 *
| > Tucson, AZ 85734-1337 *
|
| How do I download java documentation directly from eclipse? I
| my way out at java.sun.com.
| Thanks
| Jack
|
|
- Next by Date: Re: Collections.class methods anachronisms?
- Next by thread: Re: Collections.class methods anachronisms?
- Index(es):
Relevant Pages
|
|