Chapter 8

How Java Works


CONTENTS

Intranets are different from the Internet because they are private networks, set off from the rest of the world by firewalls. They also differ in that they often connect disparate corporate networks. And they often access corporate resources and databases that were built with non-Internet technology in mind.

In order to connect disparate networks, and in order to get at data residing on legacy databases and systems, custom programs need to be written. There are many ways that those programs can be created. Many people believe that the Java programming language, created by Sun Microsystems, may eventually become the programming glue that holds intranets together.

The primary reason for Java to be the programming language of choice for intranets is that it is platform-independent. That means that programs written in Java can run on a wide variety of computers, including PCs, Macintoshes, and UNIX workstations. In addition to being platform independent, Java was designed with lots of classes and methods for dealing with sockets, URLs, and other technical pieces of the process.

Java is similar to the C++ computer language that is already used by many programmers, and it is object-oriented so that new applications can be built from pre-existing components, two more reasons that intranet developers may favor the language.

Like many programming languages, Java is a compiled language, so that after it's written, it must be run through a compiler to allow computers to understand it. But in Java, only a single compiled version of the program is created. That single compiled program can run on many different computers, such as PCs, Macintoshes, and SPARC workstations. Other languages require that the completed program be compiled separately for each type of computer, which results in several different versions of the code. This requires a substantial amount of programming work and debugging.

Java is so important to intranet applications that hardware and software companies such as IBM have released special Java add-ons and libraries to allow Java developers to tap into legacy databases, such as IBM mainframes. This may accelerate the move toward Java on intranets.

Java can be used for far more than tapping into databases. It can create interactive multimedia applications as well. A common use of Java is to create a news ticker broadcasting the latest news that people can click on to get more details. This can be used 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 also allows 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 navigate through an intranet more easily, and more easily "mine" the enormous amounts of data locked up in corporate databases.

How Java Works

Java, a programming language developed by Sun Microsystems, is expected 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 also be used by programmers, editors, and artists to create multimedia programming. Java will also be able to create customized intranet programs for everything from workgroup computing to electronic commerce.

  1. Java is similar to the C++ computer language and is object-oriented, which means that programs can be created by using many pre-existing components, instead of having to write the entire program from scratch. This will be a great help on intranets, since it will allow corporate programmers to share components and so build customized applications much more quickly.
  2. Java is a compiled language, which means that after a Java program is written, the program must be run through a compiler in order to turn the program into a language that a computer can understand. Java differs from other compiled languages, however. In other compiled languages, computer-specific compilers create different executable binary code for all the different computers that the program can run on. In Java, by contrast, a single compiled version of the program-called Java bytecode-is created by a compiler. Interpreters on different computers-such as a PC, Macintosh, or SPARC workstation-understand the Java bytecode and run the program. In this way, a Java program can be created once, and then used on many different kinds of computers. Java programs designed to run inside a Web browser are called applets. Applets are a subset of Java and for security reasons cannot read from or write to local files, whereas full Java can do so. Java-enabled browsers have Java bytecode interpreters in them.
  3. After a Java applet is compiled into bytecodes, it is copied to an intranet Web server and the necessary link is put in HTML.
  4. When someone on an intranet visits a home page with a Java applet on it, the applet automatically downloads to their computer. The applet doesn't wait for an invitation. That is why there is so much concern about viruses being embedded in applets. In order to run the Java applet, you will need a Web browser that has a bytecode interpreter that can run Java applets. Many browsers designed for intranets, such as Netscape, have these built into them.
  5. Since Java applets are programs that run on your computer, they could theoretically carry a virus just like any other computer program. To help ensure that no viruses can infect your computer, when a Java applet is downloaded to your computer, the applet first goes through verification-a process that checks that the bytecodes can be safely run. However, again, applets cannot read from or write to local files which are usually involved in virus attacks, so this should reduce virus infection risk substantially.
  6. After the bytecodes have been verified, the Java interpreter in the browser puts them into a restricted area in your computer's memory and runs them. By putting the applet into this special area of your computer, further care is taken that no virus can harm your computer.
  7. The Java applet is run. Applets can query databases by presenting a list of queries or data entry forms to the user. They can assist searching intranet sites by creating more sophisticated searching mechanisms than is possible with HTML. Most important, since the client's CPU cycles are used rather than the server's, all kinds of multimedia, including animation and interactivity, are possible with Java applets.
  8. Java will have special Application Programming Interfaces (APIs) and other kind of software "hooks" to allow intranet programmers to more easily integrate intranet programs such as Web browsers with existing corporate databases and networks.