Sagewire Logo

beginner's question

7 Message(s) by 5 Author(s) originally posted in java programming


From: Jacky Luk Date:   Wednesday, September 20, 2006
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


From: Ian Shef Date:   Wednesday, September 20, 2006
wrote in message in

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've 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 do not 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 program mer 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've 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 *


From: Jacky Luk Date:   Thursday, September 21, 2006
"Ian Shef" <invalid@xxxxxxxxxxx> ¼¶¼g©ó¶l¥ó·s»D:Xns984485A746F71vaj4088ianshef@xxxxxxxxxxx
wrote in message in
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've 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 do not 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've 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 down load JAVA documentation directly from eclipse? I could not find
my way out at JAVA.sun.com
Thanks
Jack


From: Oliver Wong Date:   Thursday, September 21, 2006
wrote in message
How do I download JAVA documentation directly from eclipse? I could not
find my way out at JAVA.sun.com



I do not know how to get the JAVAdocs to appear in Eclipse (I think it
just happened "automatically"), but you can browse them online at
http://JAVA.sun.com/j2se/1.5.0/docs/api/

I usually browse them online even if they're available within Eclipse
anyway.

- Oliver


From: Ian Shef Date:   Monday, September 25, 2006
wrote in message in
How do I download JAVA documentation directly from eclipse? I could not
find my way out at JAVA.sun.com
Thanks
Jack



I do not know what you mean about Eclipse. However, the JAVA documentation
(both online and downloadable version s) are at
http://JAVA.sun.com/docs/index.html

I can not be any more specific than that because I do not know which version of
JAVA you've.

Assuming that you've the latest released version (5.0, also known as 1.5),
then you should go to
http://JAVA.sun.com/JAVAse/downloads/index.jsp
and scroll down to
"J2SE 5.0 Documentation"
and press the "Download" button.
Follow the instructions that are presented to you.

You can pick up further instructions from
http://JAVA.sun.com/j2se/1.5.0/install-docs.htmlGood luck!

--
Ian Shef 805/F6 * These are my personal opinions
Raytheon Company * and not those of my employer.
PO Box 11337 *
Tucson, AZ 85734-1337 *


From: TideRider Date:   Saturday, April 14, 2007
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 do not
have Internet connectivity.

--
wrote in message
|
| "Ian Shef" <invalid@xxxxxxxxxxx> ¼¶¼g©ó¶l¥ó·s»D:Xns984485A746F71vaj4088ianshef@xxxxxxxxxxx
wrote in message in
| >
| 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've 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 do not 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've 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 could not find
| my way out at JAVA.sun.com
| Thanks
| Jack
|
|


From: wildsaug Date:   Sunday, July 01, 2007
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 do not
have Internet connectivity.
--
TideRider
|
| "Ian Shef" <invalid@xxxxxxxxxxx>


¼¶¼g©ó¶l¥ó·s»D:Xns984485A746F71vaj4088ianshef@xxxxxxxxxxx
wrote in message in
| >
| 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've 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 do not 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've 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
could not find
| my way out at JAVA.sun.com
| Thanks
| Jack
|
|






Next Message: Job Market for JAVA - Is it rumoured to be good right now?


Blogs related to beginner's question

How to Build a User Community, Part 1
Most user communities take a typical path--the newbies ask questions, ... the comp.lang.java newsgroup was just too nasty a place to ask questions. ... to grow a user community is to get even the beginners to start answering questions. ...

Haskell Weekly News: December 12, 2006
Theres also a simple gui written in Java 5 which is in the darcs repository. ... A very Haskell-like language (CAL Quark) that offers access to Java libraries and ... from total beginner questions to highly abstruse stuff which probably ...

Dukes for beginners
Hi every body, Do you want to earn some Dukes? Try to answer the below questions: public.

Java: Call history and number
As the title states, I have two question Just to let you know, I'ma Java beginner, so I just might be calling something incorrectly. 1. I try to use the following and am not able to get the call history successfully? ...

Premium Webmaster Tips and Tools
Promotion Tip: Learn To Like Opera; Beginner Tip: Be Careful With Image Formats. March 2003 ... CSS Tip: Linking With Style; Usability Tip: That Java May Be Getting Old ... Hosting Tip: 7 Questions To Ask Your Web Host. April 1999 ...

Beginners Question: "*.java uses unchecked or unsafe operations"
comp.lang.java.help: Beginners Question: "*.java uses unchecked or unsafe operations"


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional