Results 1 to 7 of 7
  1. #1
    shwein is offline Member
    Join Date
    Sep 2008
    Posts
    38
    Rep Power
    0

    Default applet won't run in browser...

    hey, ive maid a simple test-applet in eclipse. It will run in eclipse, but if i export to a jar file and put it in my site directory it wont run; the java console gives a
    -class not found exception- ?
    here is the code and som more info, please help me...

    <code>

    package testPackage;
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.Graphics;
    import java.awt.event.*;
    import javax.swing.*;


    public class TestApplet extends JApplet implements ActionListener {
    JButton btn = new JButton("test");
    JTextField jtf = new JTextField(10);


    public void init() {

    JPanel pnl = new JPanel();
    btn.addActionListener(this);
    pnl.add(btn);
    pnl.add(jtf);
    getContentPane().add(pnl);
    }

    public void actionPerformed(ActionEvent e){
    if (e.getSource() == btn){
    jtf.setText("this is a test!");
    }
    }
    }
    </code>

    html code;

    <code>
    <APPLET CODE="TestApplet.jar" WIDTH="400" HEIGHT="200">

    </APPLET>
    </code>

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

  3. #3
    shwein is offline Member
    Join Date
    Sep 2008
    Posts
    38
    Rep Power
    0

    Default

    <code>
    <APPLET CODE="TestApplet.class" archive="TestApplet.jar" WIDTH="400" HEIGHT="200">

    </APPLET>
    </code>

    there is still a classNotFoundException in java console:

    what should the manifest file contain?, iv got an error with that to...

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Before run the applet check that class file is contain in the same location where your applet(html file) is located. manifest contain initial details to run the code, like main class name and so on.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    classNotFoundException in java console:
    Can you copy and paste the FULL text of the error message?
    The message will say what class is NOT FOUND. THAT is VERY important.
    I don't think the browser uses the manifest file for applets.
    Look in the TestApplet.jar file to see if the missing class is there and has the correct path. Rename the .jar to .zip on Windows will allow you to easily view the jar file contents.

  6. #6
    shwein is offline Member
    Join Date
    Sep 2008
    Posts
    38
    Rep Power
    0

    Default

    fixed it... i changed the content of the jar file and accordingly the html code and it works!!
    thx very much for the help!!

  7. #7
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Browser
    By Jessie Madman in forum AWT / Swing
    Replies: 20
    Last Post: 02-17-2009, 01:56 PM
  2. Browser help
    By MarkWilson in forum Advanced Java
    Replies: 5
    Last Post: 09-20-2008, 11:20 AM
  3. Need Help! swt/Browser
    By sealyu in forum SWT / JFace
    Replies: 4
    Last Post: 07-09-2008, 08:16 PM
  4. how to get url from browser
    By srinivas reddy in forum New To Java
    Replies: 0
    Last Post: 02-08-2008, 07:46 AM
  5. Replies: 4
    Last Post: 06-08-2007, 06:15 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
  •