my dog learned polymorphism
The moose likes Applets and the fly likes java applet error (new to this sorry) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "java applet error (new to this sorry)" Watch "java applet error (new to this sorry)" New topic

java applet error (new to this sorry)

Dj Driver

Joined: Nov 11, 2011
Posts: 16
Just trying to learn the basics of applets and stuck at the beginning:

I have a file named: with code:

import java.awt.*;
import java.applet.*;
<applet code="SimpleApplet" width=200 height=60>

public class SimpleApplet extends Applet {
public void paint(Graphics g) {
g.drawString("Java makes applets easy.", 20, 20);

When I type: appletviewer at the command line I receive:

Warning: <applet> tag requires code attribute.

No idea what the error message is and I do have the path correct as shown below:

Usage: appletviewer <options> url(s)

where <options> include:
-debug Start the applet viewer in the Java debugger
-encoding <encoding> Specify character encoding used by HTML files
-J<runtime flag> Pass argument to the java interpreter

The -J option is non-standard and subject to change without notice.

If anyone can help me to get this to display in the Applet Viewer I would appreciate it. Using the most recent Java 7 and working from the book, ch. 14, Java A Beginners Guide (fully updated for JDK 7) from Oracle

Thanks in advance
Tim Moores

Joined: Sep 21, 2011
Posts: 2409
The second "<applet>" should be "</applet>" instead.
Dj Driver

Joined: Nov 11, 2011
Posts: 16
and after reading your reply I implemented it and it worked. Thank you

p.s. - I also noticed that I missed the / in the book example.
I agree. Here's the link:
subject: java applet error (new to this sorry)
It's not a secret anymore!