|
Java Relies on a "Virtual Computer" |
|
In order to pull off the trick of being able to work on a variety of platforms, Java applets actually run on what's called the Java Virtual Machine. Look at it this way: There are programs available today that allow you to run Windows software on a Macintosh, or UNIX software on a Windows computer, and so on. They do this by emulating the behavior of a particular computer type (they "pretend" to be a Mac or Windows or UNIX machine so that the software thinks it's running on the correct computer). The Java Virtual Machine is another type of emulator, but it doesn't emulate Mac, Windows, or UNIX. Rather, it pretends to be a totally different type of system; and by defining what the Java computer can and cannot do, Sun was able to create a program that, no matter what physical hardware it's run on, will always look like a Java computer to the applets. |
|
The HotJava Web browser. |
|
|
Why Include an "Upgrade Utility"? |
|
There are actually two different versions of Java floating about in CyberSpace: the one that came with the HotJava browser and the one in the JDK. At the time the JDK was released, the Java language was "frozen" (no more major changes). However, there were some significant changes in Java between the release of HotJava and the introduction of the JDK. To make the transition from 1.0 Alpha 3 (the HotJava version) to 1.0 beta (the JDK version), the JDK includes a utility to help convert old applets. |
|
An .EXE File That Unpacks Itself? |
|
This is called a self-extracting archive and needs only to be "run" by you. In Windows, you can choose File, Run from the Program Manager, or in Windows 95 choose Run from the Start Menu on the taskbar. From there, the file will decompress and install itself. |
|
JDK online documentation. |
|
|
Duke waves a friendly greeting. Resist the temptation to wave back! |
|
<APPLET CODE="appletFile" WIDTH=pixels HEIGHT=pixels> <!- Alternate HTML code goes here -> </APPLET>
|
The CODE Attribute Must Be Relative |
|
Unlike most other HTML tags and attributes that use URLs, the CODE attribute cannot be an absolute URL; it must point to something relative to the current directory the HTML files are in. |
|
You Can Spot Old (pre-JDK) Applets Easily |
|
If, as you surf the Web, you come across an applet that's implemented in HTML using an <APP> tag instead of the JDK <APPLET> tag, you've found an old applet. |
<PARAM NAME=appletAttribute VALUE=value>
|
Command Line? I'm Running a Mac! |
|
If you're running a Macintosh (or a PowerPC), you're probably a bit confused by the reference to a "command line": the Mac operating system doesn't have one. Does this mean that Mac users are out of luck when it comes to creating Java applets? Sadly, at this moment, the answer is, "Yes, unless you're willing to spend some money." There are no environments or library sets (source code) for Java compiling on the Mac available for free off the Internet. Several companies (Symantec at http://www.symantec.com/ and Metrowerks at http://www.metrowerks.com/ to name two) have announced that they will be integrating Java applet creation into their compilers but their products aren't available yet. Natural Intelligence, however, does market a package called Roaster that gives Mac users the ability to compile and develop Java applets on the Mac from inside the Mac OS. For more information, check out Natural's web page at http://www.natural.com/. Keep in mind, however, that even if you were to start writing your own Java applets, there still isn't a Web browser available for the Mac that supports Java (that, too, is "coming soon"), which is another good reason to stick with JavaScript: it runs on Mac, IBM, and UNIX right now! |
/* HelloWorld.java: Hello World...Java Style */
public class HelloWorld
{
public static void main(String args[])
{
System.out.println("Hello World!");
}
}
javac HelloWorld.java
java HelloWorld
|
|