Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring 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

i'm having trouble with an applet...

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi. i have an applet which i want to run from my webpage. if my webpage's address is "www.sam.com" for example, how can i include my applet in the webpage so that people visiting my webpage can run the applet. i have a way in mind, but i'm not sure if it works:
<html>
<applet code="xxxx.class" width=50 height=50>
</applet>
</html>
a detailed responce would be highly appreciated.
thanks. sam.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not an experienced Java programmer, but in the spirit of this board I will help as much as I can.
What you have looks like it will work as long as the file xxxx.class is in the same directory as your HTML file. If not, you have to use the CODEBASE tag to specify the location of the .class file. Here is an example (my comments in square brackets -- don't include them in your HTML code):
<applet CODE="OscilaApplet1.class" [name of class file] CODEBASE="../java/" [location of class file] WIDTH="620" HEIGHT="320" HSPACE="0" VSPACE="0" ALIGN="middle">
</applet>
The "../" symbol in the codebase tag means "move up one directory." If you want to include the CODEBASE tag even though the class file is in the same directory as the HTML file, use "./" instead, which means "same directory."
When you visit an applet on a Web page that works, look at the page source to see how they did it. (In Netscape, you can see the page source by pulling down the "View" menu at the top of the browser and selecting "Page Source".) Try downloading the .class file from the hosts computer. You should always be able to download it as long as you have correctly figured out where the class file is located from the CODEBASE tag.
Hope this helps.

 
Paddy spent all of his days in the O'Furniture back yard with this tiny 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