Java appletviewer error

253 views Asked by At

I've just started messing around with Java, and I've done the following applet:

import java.applet.*;
import java.awt.*;
import java.util.*;
import javax.swing.*;

/**
 * The HelloWorld class implements an applet that
 * simply displays "Hello World!".
 */

public class HelloWorld extends Applet {
    public void paint(Graphics g) 
    {
        // Display "Hello World!"
        g.drawString("Hello world!", 50, 25);
    }
}

I've saved that, made an html document with the following:

<html>
<head>
<title>Hello World by Your Name</title>
</head>
<body>
<p>Hello World Applet

<applet code="HelloWorld.class" width=300 height=200>
</applet>

</body>
</html>

But I am getting an error saying I have an exception access violation when I am trying to view the applet in hello.html from the command prompt. Can anyone tell me why this is happening please?

1

There are 1 answers

0
iPot On

I'm not sure about this but I thought the purpose of applets was being processed by the JVM without being able to access you local system etc.. Using it inside a command prompt would totally render that concept useless since it's the 'heart' of your computer. Tell me if I'm saying utter crap.