[4668] in java-interest
Re: The Hello World Example
daemon@ATHENA.MIT.EDU (Arthur van Hoff)
Wed Jan 10 14:12:40 1996
Date: Wed, 10 Jan 1996 09:23:07 -0800
From: Arthur.Vanhoff@Eng.Sun.COM (Arthur van Hoff)
To: fritz@environs.com
Cc: java-interest@java.Eng.Sun.COM
Hi Fritz,
> I have been trying the Hello World example given at
> http://java.sun.com/tutorial/getStarted/applet/index.html. and I am quite
> confused why it does not work.
>
> I typed the following in my MS-DOS edit:
>
> import java.awt.Graphics;
> public class HelloWorld extends java.applet.Applet {
> public void init() {
> resize(150,25);
> }
> public void paint(Graphics g) {
> g.drawString("Hello world!", 50, 25);
> }
> }
>
> as instructed from the web page.
> I then compiled at my DOS prompt by typing:
>
> javac HelloWorld.java
>
> I received no compile errors. I then typed: " java HelloWorld" and I
> received the following error message:
>
> In class HelloWorld: void main(String argv[]) is undefined.
>
> I assumed that this source code is acceptable for Beta 1.0. Is this not
> true? If so, what should the source code read?
You code is trying to be an applet but you are running it as a main program.
Either you need to add a main method, or you need to create an html page that
contains the applet:
<title>
My first applet
</title>
<applet code=HelloWorld.class width=300 height=40>
</applet>
There is a detailed description of all of this in the "Hooked on Java" book.
Have fun,
Arthur van Hoff
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com