Web hosting domain names - 18 Introduction to Computers, the Internet and the

18 Introduction to Computers, the Internet and the Web Chapter 1 javac Welcome.java at the command window of your system (i.e., the MS-DOS prompt in Windows, the Command Prompt in Windows NT/2000 or the shell prompt in UNIX/Linux). If the program compiles correctly, the compiler produces a file called Welcome.class. This is the file containing the bytecodes that will be interpreted during the execution phase. Phase 3 is called loading. The program must first be placed in memory before it can be executed. This is done by the class loader, which takes the .class file (or files) containing the bytecodes and transfers it to memory. The .class file can be loaded from a disk on your system or over a network (such as your local university or company network or even the Internet). There are two types of programs for which the class loader loads .class files applications and applets. An application is a program (such as a word-processor program, a spreadsheet program, a drawing program or an e-mail program) that normally is stored and executed from the user s local computer. An applet is a small program that normally is stored on a remote computer that users connect to via a World Wide Web browser. Applets are loaded from a remote computer into the browser, executed in the browser and discarded when execution completes. To execute an applet again, the user must point a browser at the appropriate location on the World Wide Web and reload the program into the browser. Applications are loaded into memory and executed by using the Java interpreter via the command java. When executing a Java application called Welcome, the command java Welcome invokes the interpreter for the Welcome application and causes the class loader to load information used in the Welcome program. [Note: Many Java programmers refer to the interpreter as the Java Virtual Machine or the JVM.] The class loader also executes when a World Wide Web browser such as Netscape Navigator or Microsoft Internet Explorer loads a Java applet. Browsers are used to view documents on the World Wide Web called Hypertext Markup Language (HTML) documents. HTML describes the format of a document in a manner that is understood by the browser application (we introduce HTML in Section 3.4; for a detailed treatment of HTML and other Internet programming technologies, please see our text Internet and World Wide Web How to Program, Second Edition). An HTML document may refer to a Java applet. When the browser sees an applet referenced in an HTML document, the browser launches the Java class loader to load the applet (normally from the location where the HTML document is stored). Each browser that supports Java has a built-in Java interpreter. After the applet loads, the browser s Java interpreter executes the applet. Applets can also execute from the command line, using the appletviewer command provided with the J2SDK the set of tools including the compiler (javac), interpreter (java), appletviewer and other tools used by Java programmers. Like Netscape Navigator and Microsoft Internet Explorer, the appletviewer requires an HTML document to invoke an applet. For example, if the Welcome.html file refers to the Welcome applet, the appletviewer command is used as follows: appletviewer Welcome.html This causes the class loader to load the information used in the Welcome applet. The appletviewer is a minimal browser it knows only how to interpret references to applets and ignores all other HTML in a document. Copyright 1992 2002 by Deitel & Associates, Inc. All Rights Reserved. 7/8/01

Leave a Reply