|
BookMark Us
|
Please
so that you may come back to see what's new.
|
|
We're Rated With
|
|
|
|
| Adding A Java Applet To My WebPage and Making It Work
|
| It's easier than you think
|
First, you need to understand what java applet components are required
for your web page as well as understanding the required HTML statement/instructions
that make your applet work correctly on your web page. You will then be
able to install, modify and use these Java Applications with little or
no difficulty.
After you have downloaded and unzipped the applet, as most applets are
downloaded in .zip format, you will find that it will contain at least
one .class file. This is the compiled Java program.
NOTE:
There is no need to open the class files in any editor. By doing so you run the
risk of making the applet unusable.
Some applets require multiple class files and, in a few cases, a jar
file. These should be provided in the zipped file you downloaded. The linking
between these files is automatic from within one or more of these class
and/or jar files. The primary ".class" file is always stated in the first
line of the HTML source or markup tags.
Example:
<Applet code="WhatEver.class" width="in_pixels" height="in_pixels">
</Applet>
Of course this example is in its simplist form and could very well be
all that is required to make an applet work..
There can be many or no parameter specifications. The required parameters should be provided by the creator of the applet.
For the applets that have parameters, the settings can be tweaked or customized by you. Options could include: font,
font color, font size, bgcolor, audio (.au only), URLink, images (.gif
and .jpg), fade, text, etc.
Example:
<Param Name=BGcolor Value="0000ff">
<Param Name=Image Value="photo.gif">
Although it is highly recommended to put all of the class, image, audio,
etc. files into the same directory as your HTML source or markup tags for
the applet to work, it is not required. In most cases you can call the
class file with an added tag linking to the directory where the class file
is located and an image, audio, etc. file by linking to the directory where
the image, audio, etc. file is located.
Example:
<Applet codebase="directory_name"
code="WhatEver.class" width="in_pixels" height="in_pixels">
<Param Name=BGcolor Value="0000ff">
<Param Name=Image Value="images/photo.gif">
</Applet>
If you'll notice, in the previous examples, I have used both upper and
lower letter case of "WhatEver.class". This is probably the number
one reason why applets will not work. Most class files are named
in this fasion and must remain named exactly as you get them!
Also notice the codebase="directory_name" tag in the first line of the above example.
This tag is required in some cases so that the applet code in the web page knows where
to look for the .class file.
|
|
| In a NutShell
|
1. Copy and paste the applet statement into your HTML Document.
2. Tweak or modify any available parameters.
3. UpLoad the HTML document, along with
the class file(s), and any required image, audio, txt, etc. files to your
server.
NOTE: .class files and all non-text
files must be transferred in the binary mode. For best results, make certain
that the class file(s) are in the same directory as your HTML source or
markup tags!
4. If you have any trouble running the applet, recheck your syntax, spelling
(eg: Upper and Lower Case letters) as well as checking the directory you placed
your files into.
NOTE: Most servers support running
Java Applets so if they do NOT work corretly then the error is most likely
yours and not the servers.
IMPORTANT: Not all browsers are
created equal. Applets run better in IE. "Java Virtual Machine", for IE5 and up,
is the thing that executes the applets in your IE5 browser! This can be
installed from www.microsoft.com. Also be certain that your browser's "Java
JIT Compilier" is enabled. This can be done by click on tools/options/advanced
in IE5 and up.
Now for questions and answers that may help you figure out what went wrong:
Q. I'm having problems using the applets
in frontpage.. Where do i put the files for the applets?
A. The easiest way to run an applet is to put all the related
applet files (class files, images, etc.) into the same directory as the
web page you designed to display the applet. So, if your web page is in the root
folder of your site - then upload all the applet files there.
Q. I just added a new navigation applet to my website and i have it in a frame,
but when I click a link on the applet, it doesn't open in the correct frame window.
A. For the Target value, enter the "name" of the window you want the link to open in.
The "name" would be whatever you named that frame/window when you created the frameset.
An example would be <a target="center_window" href=...
Q. I cannot get my images to show in an
applet. They are all in the same directory as the applet and I have linked to them in
this way ../stars.gif
A. If you are putting all the files in the
same directory - including your web page - then you don't need the ../ in front
of the image name. ../ represents up one level in your directory.
Q. I downloaded a java applet and all of
its files... the problem is that this java applet requires 2 ".class" files... and
in the coding.. I only see they stated one ".class" file... when I try to
run it then it show that ".class" file not found
A. Some applets require more than one
class file. The main class file is stated in the applets HTML but you need
to send them all up to your server placing them into the same directory for the
applet to work. You may also need to add a line stating the code base directory like I show in the first section on this
page (<applet codebase="directory_name"). As long as all the applet files are
uploaded to the same directory, the main class file should link to the other class files without you having to do anything
more or the person who made the applet messed up somewhere.
Q. Can you run Java Applet/Servlet pairs on any server?
A. It depends on the host service. Ask your server administrator.
That should just about cover anything you, the end user, will need
to know to make your Java Applets work on your site.
|
|
Courtesy of:
|