They are both similar and quite different depending on how you look at them. First their lineage:
Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems.
You may be wondering what OOP means by now. Object Oriented Programming is a relatively new concept, whereas the sum of the parts of a program make up the whole.
Think of it this way: you are building a model car. You build the engine first. It can stand alone. It is an engine and everyone can see it’s an engine. Next you build the body. It can also stand alone.
Finally, you build the interior including the seats, steering wheel, and whatnot. Each, by itself is a object.
But it is not a fully functioning car until all the pieces are put together. The sum of the objects (parts) make up the whole.
Continuing with the model car example, when you built the engine, you didn’t use any of the parts that would later build the seats (a 350 four-barrel engine with a seat belt sticking out if the piston would look pretty silly).
The point is that all the parts that made up the engine were of a certain class of parts. They all went together. Ditto with the body and then the interior.
The point is that in these languages, you build objects out of classes of commands to create the whole. Understand the terminology? Good. Moving along…
Java is a much larger and more complicated language that creates “standalone” applications. A Java “applet” (so-called because it is a little application) is a fully contained program.
Another major difference is how the language is presented to the end user (that’s you when you’re surfing).
Java must be compiled into what is known as a “machine language” before it can be run on the Web.
Basically what happens is after the programmer writes the Java program and checks it for errors, he or she hands the text over to another computer program that changes the text code into a smaller language.
That smaller language is formatted so that it is seen by the computer as a set program with definite beginning and ending points.
Nothing can be added to it and nothing can be subtracted without destroying the program.
You can alter it after it runs and run it again and again. Once the Java is compiled, it is set. Sure, you can go back to the original text and alter it, but then you need to compile again.
Java applets run independent of the HTML document that is calling for them. Sure, they appear on the page, but the HTML document did little more than call for the application and place it.
If the programmer allows it, oftentimes parameters can be set by the HTML document. This includes the background color of the applet of the type of text it displays, etc.
So, what are the benefits of using one over the other? There are several. If you can understand Java, it is amazingly versatile.
Because of the size and structure of the language, it can be used to create anything from small Web page events to entire databases to full browsers. The program I use to track my advertising banners is Java.
Both will create great Web page events. Both can offer interaction between the user and your Web page. But they are not created equally by any means.
You simply grab them from the Net and use them on your page (provided you are given permission).