⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch1.htm

📁 Java_by_Example,初级经典例子哦,珍藏版本
💻 HTM
📖 第 1 页 / 共 3 页
字号:
version 1.0.1 has been used for many of the test applets, version1.0.2 represents Sun's latest installment of the JDK at the timeof this book's completion. However, because the language is constantlybeing refined (and was only recently released for  Windows), theremay have been a newer version released since this book was written.<P>If you'd like to be sure you have the latest version, you canfind HotJava and the JDK on the Sun Microsystems site, locatedat <TT><A TARGET="resource window" HREF="http://www.sun.com">http://www.sun.com</A></TT>. Once you connect up to Sun Microsystems'home page, navigate to the page shown in Figure 1.5, which providesaccess to tons of information about Java and enables you to downloadthe files you need. (Of course, Web pages constantly change. SunMicrosystem's site may have changed significantly by the timeyou read this.)<P><A HREF="f1-5.gif"><B> Figure 1.5 : </B><I>You can download HotJava and the Java Development Kit from Sun Microsystems' Web pages.</I></A><P><P>If you want to try out a copy of Netscape Navigator 2.0, hop ontothe ol' WWW and go to <TT><A TARGET="resource window" HREF="http://www.netscape.com">http://www.netscape.com</A></TT>, whichis Netscape's home page. From there, you can find your way tothe page shown in Figure 1.6. From this page, you can downloadany of the software that Netscape has up on the Web.<P><A HREF="f1-6.gif"><B> Figure 1.6 : </B><I>You can get Netscape Navigator 2.0 <r>from Netscape's WWW site.</I></A><P><P><CENTER><TABLE BORDER=1 WIDTH=80%><TR VALIGN=TOP><TD><B>NOTE</B></TD></TR><TR VALIGN=TOP><TD><BLOCKQUOTE>You might also want to find your way to <TT><A TARGET="resource window" HREF="http://www.microsoft.com">http://www.microsoft.com</A></TT>, where you can find information about Microsoft's new Web browser, Internet Explorer 3, which features Java support.</BLOCKQUOTE></TD></TR></TABLE></CENTER><P><H2><A NAME="ExampleInstallingHotJava"><FONT SIZE=5 COLOR=#Ff0000>Example: Installing HotJava</FONT></A></H2><P>The HotJava browser is contained in a self-extracting compressedfile, which you may download from Sun's Web site at <A TARGET="resource window" HREF="http://java.sun.com">http://java.sun.com</A>.After you extract HotJava's many files (there's a ton of them!)by double-clicking the file, the extraction program uncompressesthe files and stores them in a folder named HOTJAVA.  Once thefiles are extracted, you can copy the folder anywhere you likeon your hard disk.<P>When you examine the HOTJAVA folder, you'll see the directorystructure shown in Figure 1.7. The BIN folder contains the mainHotJava application (HOTJAVA.EXE), as well as many of the Javaenvironment's tools, including the compiler, interpreter, andprofiler.  The LIB folder contains a number of other files neededfor HotJava:<P><A HREF="f1-7.gif"><B> Figure 1.7 : </B><I>After extraction, the HOTJAVA directory will contain all of HotJava's files.</I></A><P><P><CENTER><TABLE BORDER=1 WIDTH=80%><TR VALIGN=TOP><TD WIDTH=163><BLOCKQUOTE>lib/classes.zip.</BLOCKQUOTE></TD><TD WIDTH=300><BLOCKQUOTE>This file is needed by the compiler and interpreter, so do not unzip it.</BLOCKQUOTE></TD></TR><TR VALIGN=TOP><TD WIDTH=163><BLOCKQUOTE>lib/properties/.</BLOCKQUOTE></TD><TD WIDTH=300><BLOCKQUOTE>This is the template and system defaults for the HotJava properties file. </BLOCKQUOTE></TD></TR><TR VALIGN=TOP><TD WIDTH=163><BLOCKQUOTE>lib/hotjava/ and<BR>lib/templates/.</BLOCKQUOTE></TD><TD WIDTH=300><BLOCKQUOTE>These are customizable textual elements and HTML.</BLOCKQUOTE></TD></TR></TABLE></CENTER><P><P><CENTER><TABLE BORDER=1 WIDTH=80%><TR VALIGN=TOP><TD><B>NOTE</B></TD></TR><TR VALIGN=TOP><TD><BLOCKQUOTE>Documentation for HotJava must be accessed online from the program's Help menu.</BLOCKQUOTE></TD></TR></TABLE></CENTER><P><H2><A NAME="ExampleInstallingtheJDK"><FONT SIZE=5 COLOR=#Ff0000>Example: Installing the JDK</FONT></A></H2><P>Although the compressed HotJava file contains many of the Javaenvironment's programs such as the compiler and the interpreter,the Java Developer's Kit contains the complete development suite,including some files not packaged with HotJava. For example, theHotJava compressed file doesn't include the Java debugger or theAppletviewer application, which enables you to view applets withouthaving to load them into a Web browser. The JDK also comes packagedwith over 20 sample applets. More importantly, the JDK containsthe most up-to-date documentation and tools.<P>You can find the JDK on this book's CD-ROM, in the JDK folder,or you can download the latest version of the JDK from the SunMicrosystems Web site. On the CD-ROM, the compressed file thatcontains the JDK is called JDK.EXE. After copying the file toyour hard disk (or after downloading the JDK from Sun), you installit in exactly the same way you installed the HotJava browser.That is, you double-click the self-extracting compressed file.<P>When the files have been extracted (it might take a while), youcan move the resultant JAVA folder anywhere you like on your harddisk, although you'll probably want it on the disk's root directory,which is where this book's forthcoming examples will assume it'slocated. Figure 1.8 shows the contents of the JAVA folder (atleast, the contents at the time of this writing; the developmentkit may have been revised by the time you read this).<P><A HREF="f1-8.gif"><B> Figure 1.8 : </B><I>The Java Developer's Kit will be in the JAVA folder after you extract its compressed files.</I></A><P><P>If you examine the folders that make up the JDK, you'll see thatthe BIN folder holds the developer tools, such as the compiler,the interpreter, the debugger, and the profiler. The DEMO foldercontains the many example applets that you can examine to learnmore about the Java language and how it's used. In your JAVA folder,you'll also find a file called SRC.ZIP. This compressed file containsthe source code for the classes included with the JDK.<H2><A NAME="Summary"><FONT SIZE=5 COLOR=#Ff0000>Summary</FONT></A></H2><P>Java just may be the biggest thing to hit the World Wide Web since,well, the Web itself. As you'll see in the forthcoming chapters,Java not only provides a way to create secure applications thatcan be used safely on the Internet, but the language also representsa complete shift in the way people may think about their computersin the future. Because a Java applet can be located anywhere onthe Web yet still be executable on your computer, your computer'sstorage may well expand from its tiny hard drive to include allof the Internet. As Java becomes more refined, and as more peoplelike yourself start writing Java applets and applications, thecyber world that is the Internet may never be the same.<H2><A NAME="ReviewQuestions"><FONT SIZE=5 COLOR=#Ff0000>Review Questions</FONT></A></H2><OL><LI>Give three reasons why Java is so suitable for Web applications.<LI>What's the difference between a Java applet and a Java stand-aloneapplication?<LI>Why are Java applets considered to be platform neutral?<LI>How does an Applet work within an HTML document?<LI>What are the two benefits of Java that make it an Internet-saavylanguage?</OL><H2><A NAME="ReviewExercises"><FONT SIZE=5 COLOR=#Ff0000>Review Exercises</FONT></A></H2><OL><LI>Explore the many resources available to Java programmers onthe Java WWW pages, located at <TT>http:/www.netscape.com</TT>.(Remember that some commerical online services, such as AmericaOnline, give you access to the World Wide Web.)<LI>Explore Netscape's Web pages, located at <TT>http:/www.netscape.com</TT>.<LI>If you've downloaded a copy of Netscape Navigator 2.0, installit on your system.<LI>Using the HotJava or Netscape browser, do a Webcrawler search(<TT>www.webcrawler.com</TT>) using the keywords &quot;java&quot;or &quot;java applet.&quot; Locate Applets others have written,follow the links and load them into your browser</OL><HR><CENTER><P><HR WIDTH="100%"></P></CENTER><!-- reference library footer #1--></CENTER><IMG SRC="/images/rule.gif" WIDTH="460" HEIGHT="5" VSPACE="5"ALT="Ruler image"><br><FONT SIZE="-1">Contact <a href="mailto:reference@developer.com">reference@developer.com</a> with questions or comments.<br><a href="/legal/">Copyright 1998</a> <a href="http://www.earthweb.com" target="_top">EarthWeb Inc.</a>,  All rights reserved.<BR>PLEASE READ THE <a href="/reference/usage.html">ACCEPTABLE USAGE STATEMENT</a>.<BR>Copyright 1998 Macmillan Computer Publishing. All rights reserved.</FONT></BLOCKQUOTE><!--outer table--><TD VALIGN="TOP"><!--right side ads --><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCAD1.REF" alt="Click here for more info"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCAD1.REF" alt="Click here for more info" height="88" width="88" border="0"></a><P><a target="resource window" href="http://adserver.developer.com/cgi-bin/accipiter/adclick.exe/AREA=DCAD2.REF" alt="Click here for more info"><img src="http://adserver.developer.com/cgi-bin/accipiter/adserver.exe/AREA=DCAD2.REF" alt="Click here for more info" height="88" width="88" border="0"></a><P></td></tr></table></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -