• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java applet error (new to this sorry)

 
Dj Driver
Greenhorn
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>
<applet>
*/

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:

C:\Users\Douglas\JavaABeginnersGuide\Chapter14>appletviewer
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
Bartender
Posts: 2752
38
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The second "<applet>" should be "</applet>" instead.
 
Dj Driver
Greenhorn
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic