|
-
Aug 27th, 2007, 11:50 PM
#1
Thread Starter
Hyperactive Member
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.
-
Aug 28th, 2007, 03:02 PM
#2
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
-
Aug 30th, 2007, 10:42 AM
#3
Thread Starter
Hyperactive Member
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.
-
Aug 30th, 2007, 10:48 AM
#4
Re: OBJECT tag
Try including:
Code:
srctype="application/x-java-applet"
in your Object tag as an an attribute, not just the param.
-
Aug 31st, 2007, 11:27 PM
#5
Thread Starter
Hyperactive Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|