File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Applets and the fly likes Can't run my applet on a html page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "Can Watch "Can New topic

Can't run my applet on a html page

Kitty Dayal
Ranch Hand

Joined: Jul 22, 2004
Posts: 89
I wrote a small applet to load an image on the applet. Code..

The html code going with it is

This runs fine when it is run using appletviewer from command prompt. But when I try to load it on a browser it does not load and see
Loading Java Applet failed...

Please help

Paul Santa Maria
Ranch Hand

Joined: Feb 24, 2004
Posts: 236
Sorry - as a security precaution, unsigned applets can't open local files.

Paul M. Santa Maria, SCJP
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Get rid of the CODEBASE parameter in the HTML. Provided that the gif is in the same directory as the HTML it should work.

[How To Ask Questions On JavaRanch]
Shashank Agarwal
Ranch Hand

Joined: May 20, 2004
Posts: 105
It could also be possible that the browser might not recognize the version of jdk you are using to compile the file. Try this, compile the applet for a lower rated version. You can do this in the following manner. In the shell or Dos prompt, compile the applet by entering -

javac -target 1.1

This creates the class according to JDK 1.1 specifications. It helped me solve a problem once, all the best to you.

Please tell what happened.
Submit your java application/applets for reviewing. Find codes. Become a member today -
I agree. Here's the link:
subject: Can't run my applet on a html page
jQuery in Action, 3rd edition