• 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 ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

java applet error (new to this sorry)

 
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
 
Saloon Keeper
Posts: 6454
158
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
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.
 
Proudly marching to the beat of a different kettle of fish... while reading this tiny ad
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic