Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2009
    Posts
    23
    Rep Power
    0

    Default I need help with Applets

    Trying to learn how to use applets, i hope this is the correct place to post! If it is not please direct me to the correct place and I will post there (and delete this one if i can)

    where to begin....

    When i try to open up the website i get this error in the java console:

    load: class HelloWorldApplet.class not found.
    java.lang.ClassNotFoundException: HelloWorldApplet.class
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown 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.IOException: open HTTP connection failed: url
    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)
    ... 7 more
    Exception: java.lang.ClassNotFoundException: HelloWorldApplet.class
    load: class HelloWorldApplet not found.
    java.lang.ClassNotFoundException: HelloWorldApplet
    at sun.plugin2.applet.Applet2ClassLoader.findClass(Un known Source)
    at java.lang.ClassLoader.loadClass(Unknown 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.IOException: open HTTP connection failed:url
    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)
    ... 7 more
    Exception: java.lang.ClassNotFoundException: HelloWorldApplet



    I have this code in my .php file:

    Java Code:
    <applet archive = "HelloWorld.jar"
                code= HelloWorldApplet
                width="98%"
                height="900"
                alt="ATVe is not working on your system (requires at least Sun Java 1.5)!">
    </applet>
    in the directory i have:

    index.php (which contains my applet code and some titles etc.) and HelloWorld.jar which contains:

    jar tf HelloWorld.jar
    META-INF/
    META-INF/MANIFEST.MF
    HelloWorld/
    HelloWorld/.DS_Store
    HelloWorld/HelloWorldApplet$1.class
    HelloWorld/HelloWorldApplet.class

    I am a little suspicious about that $1.class....but i do not know that much about java (it got created because of an annonymous inner class? probably something to do with using GUI or JApplet)

    my HelloWorldApplet class looks like this:

    Java Code:
    package HelloWorld;
    
    import javax.swing.JApplet;
    import javax.swing.SwingUtilities;
    import javax.swing.JLabel;
    
    public class HelloWorldApplet extends JApplet {
        //Called when this applet is loaded into the browser.
        public void init() {
            //Execute a job on the event-dispatching thread; creating this applet's GUI.
            try {
                SwingUtilities.invokeAndWait(new Runnable() {
                    public void run() {
                        JLabel lbl = new JLabel("Hello World");
                        add(lbl);
                    }
                });
            } catch (Exception e) {
                System.err.println("createGUI didn't complete successfully");
            }
        }
    }
    SORRY for the ridiculously long post i just wanted to be thorough....

    I do not know why this is not working...can anyone help me out?

  2. #2
    Join Date
    Nov 2009
    Posts
    23
    Rep Power
    0

    Default

    Wow i got it

    I changed code=HelloWorldApplet

    to

    code = HelloWorld.HelloWorldApplet


    argh..

    EDIT:

    well actually it works when i use my windows machine (which has java JDK 6) but it does not work when i use my MAC.....

    eh?? please help
    Last edited by ProgrammingPup; 12-22-2009 at 09:09 PM.

Similar Threads

  1. How do I export applets to jar
    By desert1940fox in forum Java Applets
    Replies: 7
    Last Post: 05-14-2010, 05:05 AM
  2. Can't see any Applets
    By pyr0chem in forum Java Applets
    Replies: 9
    Last Post: 12-17-2008, 05:24 AM
  3. applets on mac what´s going on?
    By willemjav in forum Java Applets
    Replies: 6
    Last Post: 04-19-2008, 08:03 PM
  4. applets & threads
    By willemjav in forum Java Applets
    Replies: 2
    Last Post: 04-04-2008, 07:59 AM
  5. Applets and dll
    By peiceonly in forum Java Applets
    Replies: 1
    Last Post: 04-01-2007, 11:16 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
  •