📄 ch8.htm
字号:
<HTML><HEAD><TITLE>Chapter 8 -- How Java Works</TITLE><META></HEAD><BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EE" VLINK="#551A8B" ALINK="#CE2910"><H1><FONT SIZE=6 COLOR=#FF0000>Chapter 8</FONT></H1><H1><FONT SIZE=6 COLOR=#FF0000>How Java Works</FONT></H1><HR><P><CENTER><B><FONT SIZE=5><A NAME="CONTENTS">CONTENTS</A></FONT></B></CENTER><UL><LI><A HREF="#HowJavaWorks">How Java Works</A></UL><HR><P>Intranets are different from the Internet because they are privatenetworks, set off from the rest of the world by firewalls. Theyalso differ in that they often connect disparate corporate networks.And they often access corporate resources and databases that werebuilt with non-Internet technology in mind.<P>In order to connect disparate networks, and in order to get atdata residing on legacy databases and systems, custom programsneed to be written. There are many ways that those programs canbe created. Many people believe that the Java programming language,created by Sun Microsystems, may eventually become the programmingglue that holds intranets together.<P>The primary reason for Java to be the programming language ofchoice for intranets is that it is platform-independent. Thatmeans that programs written in Java can run on a wide varietyof computers, including PCs, Macintoshes, and UNIX workstations.In addition to being platform independent, Java was designed withlots of classes and methods for dealing with sockets, URLs, andother technical pieces of the process.<P>Java is similar to the C++ computer language that is already usedby many programmers, and it is object-oriented so that new applicationscan be built from pre-existing components, two more reasons thatintranet developers may favor the language.<P>Like many programming languages, Java is a compiled language,so that after it's written, it must be run through a compilerto allow computers to understand it. But in Java, only a singlecompiled version of the program is created. That single compiledprogram can run on many different computers, such as PCs, Macintoshes,and SPARC workstations. Other languages require that the completedprogram be compiled separately for each type of computer, whichresults in several different versions of the code. This requiresa substantial amount of programming work and debugging.<P>Java is so important to intranet applications that hardware andsoftware companies such as IBM have released special Java add-onsand libraries to allow Java developers to tap into legacy databases,such as IBM mainframes. This may accelerate the move toward Javaon intranets.<P>Java can be used for far more than tapping into databases. Itcan create interactive multimedia applications as well. A commonuse of Java is to create a news ticker broadcasting the latestnews that people can click on to get more details. This can beused on intranets for presenting company information and news.What happens behind the scenes here is that a file is written,read, and "printed" to the screen. This process alsoallows people to choose to turn it off. Depending on the applet,the hit on the client resources (like memory) will vary. Basically,though, the larger the applet, the more resources are required.Java can also be used to create programs that help people navigatethrough an intranet more easily, and more easily "mine"the enormous amounts of data locked up in corporate databases.<H2><A NAME="HowJavaWorks"><FONT SIZE=5 COLOR=#FF0000>How Java Works</FONT></A></H2><P>Java, a programming language developed by Sun Microsystems, isexpected to be one of the cornerstones of building an intranet.Using Java, programmers can tie into corporate data from an intranet,enabling use of legacy systems such as databases. Java can alsobe used by programmers, editors, and artists to create multimediaprogramming. Java will also be able to create customized intranetprograms for everything from workgroup computing to electroniccommerce.<OL><LI>Java is similar to the C++ computer language and is <I>object-oriented</I>,which means that programs can be created by using many pre-existingcomponents, instead of having to write the entire program fromscratch. This will be a great help on intranets, since it willallow corporate programmers to share components and so build customizedapplications much more quickly.<LI>Java is a <I>compiled language</I>, which means that aftera Java program is written, the program must be run through a <I>compiler</I>in order to turn the program into a language that a computer canunderstand. Java differs from other compiled languages, however.In other compiled languages, computer-specific compilers createdifferent executable binary code for all the different computersthat the program can run on. In Java, by contrast, a single compiledversion of the program-called Java bytecode-is created by a compiler.Interpreters on different computers-such as a PC, Macintosh, orSPARC workstation-understand the Java bytecode and run the program.In this way, a Java program can be created once, and then usedon many different kinds of computers. Java programs designed torun inside a Web browser are called applets. Applets are a subsetof Java and for security reasons cannot read from or write tolocal files, whereas full Java can do so. Java-enabled browsershave Java bytecode interpreters in them.<LI>After a Java applet is compiled into bytecodes, it is copiedto an intranet Web server and the necessary link is put in HTML.<LI>When someone on an intranet visits a home page with a Javaapplet on it, the applet automatically downloads to their computer.The applet doesn't wait for an invitation. That is why there isso much concern about viruses being embedded in applets. In orderto run the Java applet, you will need a Web browser that has abytecode interpreter that can run Java applets. Many browsersdesigned for intranets, such as Netscape, have these built intothem.<LI>Since Java applets are programs that run on your computer,they could theoretically carry a virus just like any other computerprogram. To help ensure that no viruses can infect your computer,when a Java applet is downloaded to your computer, the appletfirst goes through <I>verification</I>-a process that checks thatthe bytecodes can be safely run. However, again, applets cannotread from or write to local files which are usually involved invirus attacks, so this should reduce virus infection risk substantially.<LI>After the bytecodes have been verified, the Java interpreterin the browser puts them into a restricted area in your computer'smemory and runs them. By putting the applet into this specialarea of your computer, further care is taken that no virus canharm your computer.<LI>The Java applet is run. Applets can query databases by presentinga list of queries or data entry forms to the user. They can assistsearching intranet sites by creating more sophisticated searchingmechanisms than is possible with HTML. Most important, since theclient's CPU cycles are used rather than the server's, all kindsof multimedia, including animation and interactivity, are possiblewith Java applets.<LI>Java will have special Application Programming Interfaces(APIs) and other kind of software "hooks" to allow intranetprogrammers to more easily integrate intranet programs such asWeb browsers with existing corporate databases and networks.</OL><HR><CENTER><P><A HREF="ch7.htm"><IMG SRC="PC.GIF" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="#CONTENTS"><IMG SRC="CC.GIF" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="contents.htm"><IMG SRC="HB.GIF" BORDER=0 HEIGHT=88 WIDTH=140></A><A HREF="ch9.htm"><IMG SRC="NC.GIF" BORDER=0 HEIGHT=88 WIDTH=140></A><HR WIDTH="100%"></P></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -