Results 1 to 4 of 4
  1. #1
    Josep_16's Avatar
    Josep_16 is offline Member
    Join Date
    Mar 2011
    Posts
    40
    Rep Power
    0

    Thumbs down Why doesn't this HelloWorld work?

    Hello, I just started today with appletviewer, with HelloWorld. When I try to run the applet with the appletviewer, the Appletviewer doesn't Start it, saying, traduced from spanish : "Start: subprogram not initialized". It also can't be started in Google Chrome.

    Here's the code of the applet:
    Java Code:
        //
        // Applet HolaMundo de ejemplo
        //
        import java.awt.Graphics;
        import java.applet.Applet;
    
        public class HolaMundo extends Applet {
            public void paint( Graphics g ) {
                g.drawString( "Hola Mundo!",25,25 ) ;
                }
            }
    and the html file one:

    Java Code:
    <html>
    <head>
    <applet code="HolaMundo.class" width=300 height=100></applet>
    </head>
    </html>

    I looked it some time, and I see nothing strange, what's wrong?

    Thanks for help!

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    Is the class file in the folder with the html file?

    Put the <APPLET tag in the <BODY section
    Remove the .class from the code= attribute

    Your code works for me. I put the applet tag in the source and use appletviewer on the source:
    Java Code:
    /*
    <applet code="HolaMundo.class" width=300 height=100></applet>
    */
        // Applet HolaMundo de ejemplo
        //
        import java.awt.Graphics;
        import java.applet.Applet;
    
        public class HolaMundo extends Applet {
            public void paint( Graphics g ) {
                g.drawString( "Hola Mundo!",25,25 ) ;
            }
       }
    Running: D:\Java\jdk1.6.0_25\bin\appletviewer.exe HolaMundo.java
    >>>> This worked
    0 error(s)

  3. #3
    Josep_16's Avatar
    Josep_16 is offline Member
    Join Date
    Mar 2011
    Posts
    40
    Rep Power
    0

    Default

    Finally! haha! Thanks for the help, I did it as you told me, I didn't know that the .html file was not needed ;).

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,403
    Rep Power
    25

    Default

    With my simple IDE, I can have the Appletviewer read the source file for running an applet. Also it is a good way to document how to use the applet.

Similar Threads

  1. synchronization doesn't seem to work
    By falcon53 in forum New To Java
    Replies: 2
    Last Post: 03-11-2011, 10:44 PM
  2. why this doesn't work?
    By hitesh_public in forum New To Java
    Replies: 5
    Last Post: 08-09-2010, 08:07 AM
  3. SQL statement doesn't work....
    By pbaudru in forum New To Java
    Replies: 4
    Last Post: 04-08-2010, 09:51 PM
  4. Why doesn't this work?
    By Corder10 in forum New To Java
    Replies: 1
    Last Post: 07-04-2009, 10:33 PM
  5. my loop doesn't work.. pls help???
    By ashton in forum New To Java
    Replies: 5
    Last Post: 01-16-2009, 08:24 AM

Tags for this Thread

Posting Permissions

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