1

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?

Zack
  • 661
  • 2
  • 11
  • 27
  • 2
    If you are starting to play around with Java then an applet isn't the way to go, let alone an AWT applet. This obsolete technology and not really worth learning. Start with a Java application. [Here's an article](http://programmers.blogoverflow.com/2013/05/why-cs-teachers-should-stop-teaching-java-applets/) to explain why. – Boris the Spider Dec 30 '13 at 20:15

1 Answers1

0

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.

iPot
  • 23
  • 5