Results 1 to 5 of 5

Thread: OBJECT tag

  1. #1

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Question OBJECT tag

    I'm still having trouble grasping how this thing is supposed to work. I've read numerous tutorials on it and I'm still lost.

    I wrote a stupid applet that simply prints a string to the applet. I made a web page that uses the OBJECT tag to display it on the web page. Here is the code that I used:

    Code:
    <html>
    	<head>
    		<title>Keyboard Test Applet :: Written by Greg Martin</title>
    	</head>
    	<body>
    		<center>
    			<object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-windows-i586.cab#Version=1,4,0,0" width="640" height="480">
    				<param name="code" value="KeyboardTest.class">
    				<param name="codebase" value="html/">
    				<param name="type" value="application/x-java-applet;version=1.4">
    			</object>
    		</center>
    	</body>
    </html>
    This works all fine and dandy however the applet window keeps telling me that the applet failed to initialize. I might be missing something because of it's absolute simplicity but here is the code that I have in the applet:

    Code:
    import java.applet.*;
    import java.awt.*;
    
    public class KeyboardTest extends Applet {
    	public void init() {}
    
    	public void paint(Graphics g) {
    		g.drawString("Press a key...", 20, 20);
    	}
    }
    The KeyboardTest class file is located in the same directory that the web page is in so I don't see any problem there but I can't figure out what in the world is going on. Any help would be appreciated. Thanks in avance.

    EDIT: And yes I am aware that the class id for the version of Java is lower than what's available but I figured that since I used dynamic versioning, it'd find the more recent one until I figured out how to properly use the OBJECT tag.
    Last edited by GamerMax5; Aug 27th, 2007 at 11:56 PM.

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: OBJECT tag

    try
    HTML Code:
    <param name="code" value="KeyboardTest" />
    remove the .class from the value

    And if the class file is in the same path as the web page, you should set
    HTML Code:
    <param name="codebase" value="html/" />
    value to empty string ""
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Re: OBJECT tag

    I did what you said to do but it's still saying applet uninited. I really do think that it's finding the applet class code regardless of if the extension is there or not. And as far as I can tell, there isn't anything wrong with my applet code. I can't figure out what's going on here.

  4. #4
    Banned
    Join Date
    Nov 2005
    Posts
    2,367

    Re: OBJECT tag

    Try including:
    Code:
    srctype="application/x-java-applet"
    in your Object tag as an an attribute, not just the param.

  5. #5

    Thread Starter
    Hyperactive Member GamerMax5's Avatar
    Join Date
    Nov 2004
    Location
    United States
    Posts
    388

    Re: OBJECT tag

    I did that and it still can't initialize the applet. I thought that it might have been the JRE itself so I reinstalled it and it was still doing it. I copied what the Java Console wrote out and here is what it said:

    load: class KeyboardTest.class not found.
    java.lang.ClassNotFoundException: KeyboardTest.class
    at sun.applet.AppletClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.applet.AppletClassLoader.loadCode(Unknown Source)
    at sun.applet.AppletPanel.createApplet(Unknown Source)
    at sun.plugin.AppletViewer.createApplet(Unknown Source)
    at sun.applet.AppletPanel.runLoader(Unknown Source)
    at sun.applet.AppletPanel.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: \KeyboardTest\class.class (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.applet.AppletClassLoader.getBytes(Unknown Source)
    at sun.applet.AppletClassLoader.access$100(Unknown Source)
    at sun.applet.AppletClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    ... 10 more

Posting Permissions

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



Click Here to Expand Forum to Full Width