Trying to add a simple applet to a web page

Reply

Join Date: Feb 2008
Posts: 3
Reputation: lordsvae is an unknown quantity at this point 
Solved Threads: 0
lordsvae lordsvae is offline Offline
Newbie Poster

Trying to add a simple applet to a web page

 
0
  #1
Feb 25th, 2008
Well, I was trying to add a simple applet to a web page(php nuke Home section), it didn't fin my applet, so I changed it and added it to a simple html file to make it as simple as I could get it.

This is the code in the html file:

  1. <applet code="usblock.class" width="400" height="400">The browser doesn't support applets...</applet>
  2.  

The directory: www/usblock.html & www/usblock.java & www/usblock.class - As you can see the files are all in the same directory/folder.

usblock.java code:
  1. import javax.swing.*;
  2. import java.awt.*;
  3.  
  4. public class usblock extends JApplet
  5. {
  6.  
  7. public void init()
  8. {
  9. JPanel p = new JPanel(new BorderLayout());
  10. p.add(new JLabel("Heisann"));
  11. add(p, BorderLayout.CENTER);
  12. }
  13. }

now as I open the html local on my computer, it workes. As soon as I open the usblock.html from my website, it doesn't.
It gives me this error here:
  1. load: class usblock.class not found.
  2. java.lang.ClassNotFoundException: usblock.class
  3. at sun.applet.AppletClassLoader.findClass(Unknown Source)
  4. at java.lang.ClassLoader.loadClass(Unknown Source)
  5. at sun.applet.AppletClassLoader.loadClass(Unknown Source)
  6. at java.lang.ClassLoader.loadClass(Unknown Source)
  7. at sun.applet.AppletClassLoader.loadCode(Unknown Source)
  8. at sun.applet.AppletPanel.createApplet(Unknown Source)
  9. at sun.plugin.AppletViewer.createApplet(Unknown Source)
  10. at sun.applet.AppletPanel.runLoader(Unknown Source)
  11. at sun.applet.AppletPanel.run(Unknown Source)
  12. at java.lang.Thread.run(Unknown Source)
  13. Caused by: java.io.IOException: open HTTP connection failed.
  14. at sun.applet.AppletClassLoader.getBytes(Unknown Source)
  15. at sun.applet.AppletClassLoader.access$100(Unknown Source)
  16. at sun.applet.AppletClassLoader$1.run(Unknown Source)
  17. at java.security.AccessController.doPrivileged(Native Method)
  18. ... 10 more

So I thought it was that it couldn't find the .class file. Well, I went through the How To add applets that I found somewhere on sun.com. It had exactly the same as I had.

Im figuring the problem is something easy and not hard to detect. But my eyes can't find it somehow. This is my second time trying applets, and I kinda forgot how I got it to work the first time.

Im just glad for all the help I can get.
Thanks a lot.
LordSvae

PS: Sry for the size of the post, but I'm not sure how much info I was supposed to put in here, so I thought the more the better, right?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC