Results 1 to 11 of 11

Thread: Applet in Html

  1. #1
    durduman is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default Applet in Html

    I am trying to integrate a basic applet in a basic html file and when i open the html file with firefox the space dedicated for the applet is blank and has an error notificaton on the top of it and when I click it for details this message appears:


    Java Plug-in 1.6.0_23
    Using JRE version 1.6.0_23-b05 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Durdu
    ----------------------------------------------------
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------


    load: class “Exemplu.class” not found.
    java.lang.ClassNotFoundException: “Exemplu.class”
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\Users\Durdu\Desktop\ml\applet\“Exemplu\class”.c lass (The system cannot find the path specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unk nown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(U nknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknow n Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 9 more
    Exception: java.lang.ClassNotFoundException: “Exemplu.class”



    I tried putting "exemplu.class" in both dir (C:\Users\Durdu\Desktop\ml\applet\“Exemplu\class and User home directory = C:\Users\Durdu ) and nothing works.


    the applet class is called "Exemplu" with the extension ".class" .

    the html code:


    <html>
    <head>
    <p>test head</p>
    </head>
    <body>
    <p>test</p>
    <APPLET CODE = “Exemplu.class” WIDTH=100 WEIGHT=100> </APPLET>
    </body>
    </html>


    the applet code:



    import java.awt.*;
    import java.applet.* ;
    public class Exemplu extends Applet{
    /**
    *
    */
    private static final long serialVersionUID = 1L;
    private static Font ff = new Font ("Courier",
    Font.BOLD,16);
    private Button buton (String nume){
    Button b = new Button (nume) ;
    b.setFont(ff);
    return b;
    }
    private void CreeazaButoane(){
    a = buton("A");
    b = buton("B");
    c = buton("C");
    d = buton("D");
    e = buton("E");
    f = buton("F");
    g = buton("G");
    }
    private Panel CreeazaPanel(LayoutManager tip_plasare){
    Panel p = new Panel();
    p.setLayout(tip_plasare);
    return p;
    }
    public void init(){
    setLayout(new FlowLayout(FlowLayout.CENTER,4,1));
    CreeazaButoane();
    linie1 = CreeazaPanel(new FlowLayout
    (FlowLayout.LEFT, 4,2));
    linie1.add(a);
    linie1.add(b);
    linie1.add(c);
    linie1.add(d);
    add(linie1);
    pef = CreeazaPanel(new BorderLayout(2,2));
    pef.add("North", e);
    pef.add("South", f);
    pefg = CreeazaPanel(new BorderLayout(2,2));
    pefg.add("West", pef);
    pefg.add("East", g);
    add(pefg);
    }
    public void paint(Graphics gg){
    setSize(linie1.getSize().width,
    4*a.getSize().height);
    validate();
    }
    private Panel linie1, pef, pefg;
    private Button a, b, c, d, e, f, g;
    }


    hope anyone can help out! thx in advance from some random noob! :)

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by durduman View Post
    the html code:

    <html>
    <head>
    <p>test head</p>
    </head>
    <body>
    <p>test</p>
    <APPLET CODE = “Exemplu.class” WIDTH=100 WEIGHT=100> </APPLET>
    </body>
    </html>
    Drop that ".class" part from your code tag value.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    durduman is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    the style of error continued but now the box with the error sign for the applet in the browser turns black after a while and when I clicked for details I got this:


    Java Plug-in 1.6.0_23
    Using JRE version 1.6.0_23-b05 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Durdu
    ----------------------------------------------------
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------


    load: class “Exemplu” not found.
    java.lang.ClassNotFoundException: “Exemplu”
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\Users\Durdu\Desktop\ml\applet\“Exemplu”.class (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unk nown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(U nknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknow n Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 9 more
    Exception: java.lang.ClassNotFoundException: “Exemplu”

  4. #4
    durduman is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Java Plug-in 1.6.0_23
    Using JRE version 1.6.0_23-b05 Java HotSpot(TM) Client VM
    User home directory = C:\Users\Durdu
    ----------------------------------------------------
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    ----------------------------------------------------


    load: class “Exemplu” not found.
    java.lang.ClassNotFoundException: “Exemplu”
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass0(U nknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager.createApplet(Unk nown Source)
    at sun.plugin2.applet.Plugin2Manager$AppletExecutionR unnable.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\Users\Durdu\Desktop\ml\applet\“Exemplu”.class (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...onnect(Unknown Source)
    at sun.net.http://www.protocol.file.FileURLConn...Stream(Unknown Source)
    at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unk nown Source)
    at sun.plugin2.applet.Applet2ClassLoader.access$000(U nknown Source)
    at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknow n Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 9 more
    Exception: java.lang.ClassNotFoundException: “Exemplu”

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by durduman View Post
    Caused by: java.io.FileNotFoundException: C:\Users\Durdu\Desktop\ml\applet\“Exemplu”.class (The system cannot find the file specified)
    Are you sure your file name contains those back double quotes? My guess is that you copied that line from an electronic text without checking the actual text.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  6. #6
    durduman is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Thank you! I can't describe what feeling I have :P... embarrassed and grateful... :)

  7. #7
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by durduman View Post
    Thank you! I can't describe what feeling I have :P... embarrassed and grateful... :)
    You can put part of the blame on that stupid html parser; html is a bunch of crap: strictly speaking property values are supposed to be double quoted but not so strictly speaking non quoted property values are allowed. And then you get this: back quotes are not considered quotes so they are part of the value; bah.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  8. #8
    durduman is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    Thx for the info! :) also, do you have any particular recommendation how to learn java efficient ?

  9. #9
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by durduman View Post
    Thx for the info! :) also, do you have any particular recommendation how to learn java efficient ?
    The Sun/Oracle Tutorials are quite a good start; also read a couple of books but avoid each and every book writteln by Herbert Schildt; his books are complete crapola.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  10. #10
    durduman is offline Member
    Join Date
    Feb 2011
    Posts
    6
    Rep Power
    0

    Default

    many thanks for the third time here! :D

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,436
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by durduman View Post
    many thanks for the third time here! :D
    You're welcome of course.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Add 3D applet to html page
    By Dennis in forum Advanced Java
    Replies: 24
    Last Post: 08-01-2010, 01:07 PM
  2. Filechecker in html via applet
    By gkirca in forum New To Java
    Replies: 3
    Last Post: 12-22-2009, 10:35 AM
  3. Two Form Applet in html
    By barusk in forum Java Applets
    Replies: 0
    Last Post: 03-16-2009, 05:36 PM
  4. Embedding Applet into HTML?
    By Unome in forum Java Applets
    Replies: 1
    Last Post: 02-21-2009, 03:40 AM
  5. Chat Applet in HTML
    By Flynazn in forum Java Applets
    Replies: 3
    Last Post: 05-27-2008, 09:26 AM

Posting Permissions

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