Results 1 to 4 of 4
  1. #1
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Simple First Applet wont run

    I am learning Java through a couple of books including “Java, A beginner’s Guide” by oracle press. All was going well until I got to Applets . Even the first Applet example program isn’t running. Here is the example file (page 515 of Oracles beginners guide).
    The file name is SimpleApplet.java

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

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

    I run this with the following command:

    C:>appletviewer SimpleApplet.java

    After that, the applet box appears on the screen, but the text “Java makes applets easy” is missing. Instead it says “start:applet not initialized” (inside the applet window)

    And I get the following errors in the command window:

    load: Class SimpleApplet not found.
    java.lang.ClassNotFoundException: SimpleApplet
    at sun.applet.AppletClassLoader.findClass(AppletClass Loader.java:219)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:4 24)

    and about 8 more errors that go on and on. This is the first applet example in the book and seems so easy so I am confused why it doesn’t work. Any help appreciated.

    Thanks,
    Drew

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    19,965
    Rep Power
    31

    Default Re: Simple First Applet wont run

    java.lang.ClassNotFoundException: SimpleApplet
    Is there a SimpleApplet.class file in the same folder with the SimpleApplet.java file so that the appletviewer program can find it?

    You need to use the javac command to compile the .java program to create the .class file.
    Last edited by Norm; 07-27-2015 at 02:48 PM.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: Simple First Applet wont run

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Drew345 is offline Member
    Join Date
    May 2015
    Posts
    31
    Rep Power
    0

    Default Re: Simple First Applet wont run

    Thank you. That worked. It seems so clear now....

Similar Threads

  1. Replies: 2
    Last Post: 10-31-2012, 12:24 AM
  2. .jsp wont find my applet.class Whats going on?
    By Krooger in forum Java Applets
    Replies: 0
    Last Post: 05-08-2012, 03:54 AM
  3. Applet Wont Show Supposed Output, Please Help
    By bdmchamp in forum Java Applets
    Replies: 2
    Last Post: 06-29-2011, 01:54 PM
  4. Applet Wont Show Supposed Output, Please Help!!!!
    By bdmchamp in forum New To Java
    Replies: 7
    Last Post: 06-26-2011, 11:43 PM
  5. simple problem - code wont compile
    By dirtycash in forum New To Java
    Replies: 1
    Last Post: 11-20-2007, 05:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •