Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Running an applet in a web browser.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I made a simple applet and a simple html file to run this applet in a browser. But when I load the html file into a web browser it told me that MyApplet could not be found. I tried "appletviewer MyFile.html" in the shell and it worked. Does any body have an idea about this problem? My CLASSPATH contains only "."
Thank you in advance.
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Houssam,
Make sure that you have your HTML and jar/class files in the same directory. Load it into your browser using open as a file.
Regards,
Manfred.
 
Houssam Haitof
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your interest, yes the html file and the class file are in the same directory. I load my file using File/Open or just by double clicking on it and it still does not work :/
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure you refer to the right class. Thus, if the applet lies in a package called "mypackage" and the applet classfile is called MyApplet.class a legal name for the class would be "mypackage.MyApplet.class".
E.g.
This is the applet-tag(note: the classloader looks for the classes, begining from the html-document)
<Applet code="mypackage.MyApplet.class" width="300" height="300"></Applet>
Another example:
If you put your classes in a jar-file you could use the "archive" attribute like this.
<Applet code="mypackage.MyApplet.class" archive="myarchive.jar" width="300" height="300"></Applet>
Note:When you put your classes in a jar the browser only opens one connection and loads all the classes at the same time. Otherwhise the browser opens a new connection for each file it download.
regards,
/Peter

Originally posted by Houssam Haitof:
Thank you for your interest, yes the html file and the class file are in the same directory. I load my file using File/Open or just by double clicking on it and it still does not work :/


 
You have to be odd to be #1 - Seuss. An odd little ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic