Introduction to Java



The Java language was designed at Sun Microsystems over a five year period, culminating in its first release in January 1996. The developers, led by James Gosling, originally set out to build a language for controlling simple home devices with embedding microcomputers. Thus, they started with the object-oriented concepts of C++, simplified it, and removed some of the features, such as pointers, that lead to serious programming errors. While the team may have originally had in mind compiling this language for a specific microprocessor, instead they developed both the Java language and a hypothetical processor called the Java Virtual Machine or JVM. The Java compilers they developed produced binary code designed to execute on the JVM rather than on a PC or Sun workstation. The team’s working name for this evolving language was “Oak,” but as it neared completion, they found that Oak was already registered as a trademark. As the story goes, they came up with the name “Java” while taking a break at a coffee shop.

Executing Java Programs on Real Computers
To actually execute Java programs, they developed Java interpreters that ran on various machines and under various operating systems. Thus, Java became a language that would execute on a number of systems and now has implementations for virtually all common computers and operating systems. Sometime during development, it suddenly became obvious that Java would be an ideal language for use on the Internet, the popularity of which was growing at a phenomenal rate. They added a window manager to allow easy development of user interfaces; they also added network communication methods such as Web page URLs and sockets.
Since Java could now run on nearly any kind of workstation, it became an ideal vehicle for adding powerful computational capabilities to Web pages.

Java Applets
A Java applet is a program designed to be embedded in a Web page. Applets can be quite complex; they are not limited to simple animations or single windows. They can access remote databases or other sources of information and load and operate on complex information on your computer system. Java applets are designed to be quite secure, however. They can be safely downloaded over a network without causing concern that they might be able to do damage or mischief to your computer. They cannot write any information onto your hard disk unless you specifically give them access to a directory. They cannot access any other resources on your network or any other hardware or peripherals on your computer. Java applets are also restricted from writing into memory outside of the Java address space. This is accomplished mainly because Java has no memory pointer type and thus a malicious programmer cannot point to memory he or she might want to attack. Java applets are also scrutinized class by class as they are loaded by the run-time environment in your browser, and checks are made to assure that the binary code has not been modified such that it
might interact with or change any part of the memory of your system. Further, applets cannot access resources on any other computer on your network or elsewhere on the Internet, with one exception; they can open TCP/IP connections back to the machine running the Web server from which they were downloaded. To add even more protection and prevent programmers from spoofing users into giving them confidential information, all windows that you pop up from an applet have a banner along the bottom reading  “Unsigned Java Applet.” The banner serves to prevent hackers from designing an exact copy of a familiar screen and luring users to type confidential information into it.

Java Applications
By contrast, Java applications are full-featured programs that run on your computer and have full access to its resources. They can read, write, create, and delete files and access any other computer on the network. You will quickly appreciate that it is possible to develop full-fledged applications in Java: database viewers, word processors, spreadsheets, math packages, and file and network manipulation programs. In fact, one of Java’s great strengths is that it makes accessing other computers on your network extremely easy. Now you can write quite sophisticated programs in many other languages, so you might ask whether Java is really “ready” for all this attention. 

Advantages of Java
The advantages of Java are substantial for both simple applications and for complex server code.
1. Java is object oriented. Java requires that you write 100 percent
object-oriented code. As we will see, object-oriented (OO) programs
are easier to write and easier to maintain than the spaghetti code that is often the result of programming in other languages.
2. Java works on most platforms. While C/C++ programs are platform specific, Java binary byte code runs identically on most Unix machines, Macintoshes, and PC’s running Windows 95/98/ NT, Windows 2000, and Linux.
3. Java is network enabled. It is trivially simple to write code in Java
that works across networks. The use of URLs, TCP sockets, and
remote classes is essentially built into the language.
4. Java is multithreaded. You can write programs in which several
sections run simultaneously in different execution threads.
5. Java allows you to add major function to Web pages. If you are
interested in building interactive World Wide Web pages that
compute, collect, or display data, Java is the language of choice.
There simply is not a better way to add interactive controls to Web
pages. With all of these pluses, the only possible drawback is that you’ll have to learn a new language. This is, of course, what this book is about and we’ll see some very significant advantages to Java as we begin to explore it.



0 comments:

Post a Comment