Java


Java

Java is an object-oriented progamming language that was derived from C++. Java is platform-independent. This means that a java program compiled on one operating system will run on any operating system. How is this accomplished? In most programming languages, when source code is compiled, a platform-dependant executable file is created (machine code). Java, when compiled, generates a file containing "bytecodes" which are then interpreted by a "Java-capable" browser or interpreter written for the specific operating system. The additional step of interpreting slows down the execution of a Java program only slightly and adds the benefit of platform-independence.

Teaching how to program using Java is outside of the scope of this reference. You can find more information on Java programming at http://java.sun.com/docs/books/tutorial/index.html.

 


Java Applets

A Java Applet is a program written with a subset of the Java programming language designed to run on a Web page. Java Applets are unable to access any sensitive areas of your computer system allowing you to run them with little worry of them doing damage to your system. There are numerous Java applets available on the Web as free downloads. They are incorporated into your html document along the same lines as cgi scripts. Store the Java Applet file in the directory with your html file that uses it. Java and Java Applette files use the .class file extension. Here is the html code used to add this clock to this page.

<applet code="Clock2.class" width=170 height=150>

<param name=bgcolor value="ffffff">

<param name=fgcolor1 value="ff0000">

<param name=fgcolor2 value="ff00ff">
  
 </applet> 

This is a somewhat unique applet in that it allows you to set the colors through param commands.

Many users use Java Applets to add animation to their Web page; however Java Applets can provide many useful functions to your Web page as well.

In many cases it is the Java Applet "code" ( a .java file) that is available to download. In such cases, you will need to download and then compile the code yourself to create the .class file. You can download a Java compiler for free from the authors of the Java language at http://java.sun.com/products/jdk/1.1/. View readme.txt for instructions on compiling.

More Java applets can be found at the following URL's and by doing a Web search on "Java Applets".

http://java.sun.com/applets/js-applets.html

http://www.ccobb.org/javalinks.html

 


Java Script

Java Script is not Java. It is a scripting language that is not compiled. You do not use it to create programs as you do with Java, but rather it is used to automate Internet and Web page tasks. Tasks that supply a useful or entertaining service to the Web page viewer and/or author. Here is an example of a Java Script that has checked out some information on the type of browser that you are using to view this page and reports its findings in the following table.

Information about your Browser:

Browser Name:
Browser Version:
Browser Code Name:
User-Agent:

Here's the steps I used to add this Java Script to ths page:

STEP ONE: Copy this code into the HEAD of your HTML document

<HEAD>
<SCRIPT>
<!-- Begin
function whatBrowser() {
document.Browser.Name.value=navigator.appName;
document.Browser.Version.value=navigator.appVersion;
document.Browser.Code.value=navigator.appCodeName;
document.Browser.Agent.value=navigator.userAgent;
}
// End -->
</SCRIPT>

 

STEP TWO: Add the onLoad event handler to the BODY of your HTML document

<BODY onLoad="whatBrowser()">

STEP THREE: Add this last code into the BODY of your HTML document

<CENTER>
<TABLE BORDER>
<FORM NAME="Browser">
<TR><TD> Browser Name: </TD>
<TD> <INPUT TYPE="txt" NAME="Name" Size="45"></TD></TR>
<TR><TD> Browser Version: </TD>
<TD> <INPUT TYPE="txt" NAME="Version" Size="45"></TD></TR>
<TR><TD> Browser Code Name: </TD>
<TD> <INPUT TYPE="txt" NAME="Code" Size="45"></TD></TR>
<TR><TD> User-Agent: </TD>
<TD> <INPUT TYPE="txt" NAME="Agent" Size="45"></TD></TR>
</FORM>
</TABLE>
</CENTER>

 

You can view, try out, and download a variety of Java Script files at http://javascriptsource.com/main.html.