AW: beginner's question



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 downloaded
local copies. For either,
you go into the Java Build Path properties for that library (starting
with rt.jar!) and set the Javadoc
location. For a Java 5 rt.jar, you can set the Javadoc location to
http://java.sun.com/j2se/1.5.0/docs/api/
.
You can also download the documentation from sun.java,com and unzip it
into a location on your
computer. I do that for the APIs I use most, because I sometimes work
on code when I don't
have Internet connectivity.

--
TideRider


"Jacky Luk" <jl@xxxxxxxxxx> wrote in message
news:451248fa@xxxxxxxxxxxx
|
| "Ian Shef" <invalid@xxxxxxxxxxxxx>
¼¶¼g©ó¶l¥ó·s»D:Xns984485A746F71vaj4088ianshef@xxxxxxxxxxxxxxxxxx
| > "Jacky Luk" <jl@xxxxxxxxxx> wrote in news:45116ca0$1@xxxxxxxxx:
| >
| >> 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
String,
| > not
| > 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
"java".
| > Get the javadocs and use them. They are your friend.
| >
| > 2)
| > Note for the future: When java tells you that it cannot find a
method, it
| > is vital to remeber that the method must match both in name and
in
| > signature. Method definitions don't match method calls unless a
method of
| > the correct name can be found that has a parameter list that also
matches
| > the one used for the call.
| >
| > 3)
| > If I saw an experienced java programmer writing this program, I
might
| > figure that they are writing a mixed application/applet or
otherwise doing
| > something clever -- maybe providing a way to test an applet
without
| > requiring an applet viewer. However, when someone who describes
themself
| > as a beginner writes this way, I get concerned.
| >
| > Your class extends Applet, indicating that you intend this program
to be
| > an
| > Applet. However, you have a method "main", indicating that you
intend
| > this
| > program to be an application. Furthermore, you used "java" to run
it,
| > again indicating that your intent was for an application.
| >
| > If your intent was cleverness or a mixed application/applet,
please
| > forgive
| > me. Otherwise, you need to re-think what you are doing and decide
whether
| > you want an application or an applet. Then rethink your design.
| >
| > 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
couldn't find
| my way out at java.sun.com
| Thanks
| Jack
|
|
.



Relevant Pages

  • How to use Log4net TelnetAppender and Trace Listeners
    ... Is there a way to use Log4net and Trace Listeners? ... public static void Initialize(string traceListeners, ... public static void Flush2File(string file, string msg, bool ...
    (microsoft.public.dotnet.framework)
  • Re: must find print packages which can deal with large charts
    ... list available printers, query a named printer, print text and image files ... String inputFileName = null; ... printToFile(outputFileName, outputFileType, ... public static void queryServices{ ...
    (comp.lang.java.gui)
  • Re: programming concepts > specific languages
    ... > public static void manipulateString{ ... > What actually happens in Java though is "String A" gets printed out. ... public static void manipulateObject(Object objectToManipulate) ...
    (comp.programming)
  • nullpointer exception while try to retrieve the elements from the array object
    ... Menu mainMenu = new Menu; ... public static void getConsolidateMenu(Menu menu, Element current, ... mainMenu.setSubMenu(subMenu); ... String description; ...
    (comp.lang.java.programmer)
  • Re: Get regular expression
    ... "ABLATION LESION HEART BY PERIPHERALLY INSERTED CATHETER 37.34", ... private string _text; ... public Entry(string text, string citation): ... public static void AddToList(string line, string citation, ArrayList ...
    (microsoft.public.dotnet.languages.csharp)