• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

java applet error (new to this sorry)

Posts: 16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just trying to learn the basics of applets and stuck at the beginning:

I have a file named: SimpleApplet.java 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 SimpleApplet.java at the command line I receive:

C:\Users\Douglas\JavaABeginnersGuide\Chapter14>appletviewer SimpleApplet.java
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
Saloon Keeper
Posts: 6454
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The second "<applet>" should be "</applet>" instead.
Dj Driver
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic