Results 1 to 6 of 6
  1. #1
    rish is offline Member
    Join Date
    Jun 2014
    Rep Power

    Default Java Applet error

    please help me with this basic applet program
    i'm beginner and need some clarification with working of this program!

    import java.awt.Graphics;
    import java.awt.Font;
    import java.awt.Color;
    public class Helloapplet extends java.applet.Applet{
    Font f=new Font(“TimesRoman”,Font.BOLD,36);
    public void paint(Graphics g)
    g.drawString(“Hello again!”, 5, 50);

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power

    Default Re: Java Applet error

    What does this code do? What do you expect it to do?
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Java Applet error

    @OP: I moved your post to its own thread (you hijacked an old zombie thread). b.t.w. why are you using Applets instead of JApplets? Did you read the API documentation for those classes?

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    rish is offline Member
    Join Date
    Jun 2014
    Rep Power

    Default Re: Java Applet error

    i want this applet to get displayed in my browser by writing this html script..
    <TITLE>Another Applet</TITLE>
    <P>My second Java applet says:
    <APPLET CODE=”HelloApplet.class” WIDTH=200 HEIGHT=50>

    but this applet program is showing compilation error!!

  5. #5
    kneitzel is offline Senior Member
    Join Date
    Feb 2014
    Rep Power

    Default Re: Java Applet error


    why don't you give us the error details? That would help us to help you. It is very likely that we take the time to read your post. But it is very unlikely that we copy and past your code in the hope that you provided the correct code and that we get the exact same error.

    I just had a quick look: error: class, interface, or enum expected
    So in line 4 the { is wrong. instead "class", "interface" or "enum" is expected. It is quite self explaining, don't you think?

    When you fix that problem you might run into the next problem: You might have used the wrong quotes. In java you have to use the " and no quotes that go to the right or left as it is used when writing text in a word processing application.

    And at the end you might run into trouble because most things are case sensitive:
    Your class has the name "Helloapplet"
    So the .java file should be ""
    And the .class file is then "Helloapplet.class"
    So you should write it that way in your html file, too. (Maybe an operating system like Windows does not have problems that way but other applications are case sensitive and you should simply take care of that!)


  6. #6
    rish is offline Member
    Join Date
    Jun 2014
    Rep Power

Similar Threads

  1. java applet error
    By The "G" in forum New To Java
    Replies: 3
    Last Post: 06-02-2014, 09:13 PM
  2. Java Applet Security Error
    By zachvac in forum Java Applets
    Replies: 1
    Last Post: 04-10-2014, 12:58 AM
  3. java applet error
    By jobud9 in forum New To Java
    Replies: 9
    Last Post: 01-21-2012, 08:36 PM
  4. Certification Error on Java Applet
    By netsuvi in forum Java Applets
    Replies: 0
    Last Post: 06-21-2011, 11:16 AM
  5. Java Applet Runtime error
    By sarwar1234 in forum Java Applets
    Replies: 12
    Last Post: 09-21-2010, 03:26 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