Java is a programming language that can be used to create programs that you can link into your web pages to provide more functionality. Because Java is a proper programming language, it can be used to provide quite sophisticated functionality both in your web pages and elsewhere. One thing that you do have to remember though is that many web visitors browse with Java turned off and so will miss out on any effects that you implement with Java.
Unless you are (or want to be) a programmer, you are unlikely to want to create your Java programs yourself. There are a number of web sites that you can visit that will provide you with pre-built Java programs where all that you need to do is to copy the appropriate code into your page in order to incorporate the program. Most likely the site where you get your Java program will ask you to provide the necessary parameters that are needed to customize the output to meet your requirements and will then supply you with the finished code to incorporate into your page. Alternatively, you may be supplied with a template of the necessary code along with a set of instructions on how to customize it.
You'll find some sites where you can obtain Java programs on my webmaster links page.
So now let's look at how we go about incorporating a Java program into your web page.
For this example I will use a Java animation that I built using HotMedia. The rest of the discussion on this page will refer specifically to this Java program but the general steps involved in adding any Java program to your page will be similar (although the way that you generate your customizations may not be.
In this instance you download the HotMedia program and install it on your own PC, you then build your Java animation with this program and then publish it to create both the HotMedia .mvr file and a .htm file containing the code that you need to place into your page. Publishing your output will also save a number of other files that will also need to be uploaded to your web site. The names of these files all start with hm35 and end with .class. Alternatively, you can get the program to create a compressed version of these class files and upload the resultant .zip file instead (although if you do this your Java wont work with Internet Explorer 3). If you generate this compressed file then the resultant code that is generated will have an archive= parameter added to it to reference the zip file.
The code that you need to place into your web page to incorporate the Java program starts with <applet and ends with </applet>. You just need to extract that section from the sample web page that was built when you published your HotMedia file (or alternatively build the rest of your web page into that file). The content of this code will depend on what you create with the HotMedia program and what you enter into the Options notebook that can be found in that program's File menu. If I was going to load all of the class files separately I would further modify the code in order to put all of the files associated with the Java program into their own sub-directory on the server (I would call this java), the modification that I would need to make to do this is to add codebase="java" into the applet tag.
For the example Java program that I generated the resultant code looks like this:
<PARAM NAME="mvrfile" value="quote.mvr">
If I uploaded both ht35ani.zip (which contains the HotMedia Java programs) and quote.mvr (which is the data file for my animation) to the server along with an html page that references the Java using the above applet code, the result would be a Java animation that is somewhat fancier than can be obtained using animated gifs.
Rather than slow this page by adding the Java here, I have provided a sample Java page that you can download and use to test out the options I have discussed above and any ideas of your own. Since Java runs in the browser rather than on the server you can test your various modifications to the Java code on your own computer rather than having to upload everything to your web site.
If you can't see the Java animation when you browse the attached page then you have one of the following problems:
You don't have to have Java turned on in your own browser in order to incorporate Java effects into your web pages although it makes things easier if you do since you can then see what your Java looks like. You do need to remember that anyone who has Java turned off will not see your Java so you shouldn't use it for anything critical to the functioning of your site.
The other thing to remember about Java is that the programs can be quite large and so it might take some time for the program to download and the effect to start working, this may affect where you decide to place the program on your web page.
If you can see your Java working with the page on your computer still doesn't mean that it will work when you upload it to your web site. If you are using a free web host then there may be some restrictions on the types of files that you are allowed to upload to the site. With this example we have a HotMedia data file which is not a file type recognised by many free web servers and hence this example Java cannot be uploaded to one of those servers.
You can find Java programs that do lots of different things that will add movement and colour to your web pages. The animation I have included here is just one simple example. The files that you need to upload for your Java program will be different from this example but the code to incorporate into your page should look similar. Java is one of the easiest ways to bring life to your web site.
This article written by Stephen Chapman, Felgall Pty Ltd.