Java has a very big history behind its creation and how do we write, compile or run Java programs. Before delving into Java programs, let us first look into the history behind its development and usefulness
The creation of Java
Somewhat surprisingly, the original impetus of Java was not the Internet! Instead the primary motivation was the need for a platform independent language that could be used to create software. Those softwares were later to be embedded in various consumer electronic devices such as microwave oven and remote controls.
Java was conceived by James Gosling, Patrick Naughton, Chris Wrath, Ed Frank, and Mike Sheridan at Sun Microsystems,Inc. It took 18 months to develop the first working version. The language was initially called “Oak” but was renamed “Java” in 1995.
As the details were being worked out, another more important factor was emerging that would play a crucial role in the future of Java. This second force was, of course, the World Wide Web (www). Had the web not taken shape at about the same time Java was being implemented, Java might have remained a useful but obscure language for programming consumer electronics. However, with the emergence of the World Wide Web, Java was propelled to the forefront of computer language design, because the web too demanded portable programs.
How Java changed the Internet?
The Internet helped catapult Java to the forefront of programming. Java, in turn, had a profound effect on the internet. In addition, Java innovated a new type of networked program called the applet that changed the way the online world thought the content.
An applet is a special kind of Java program that is designed to be transmitted over the internet. It automatically executed by a Java-compatible web browser. Furthermore, an applet is downloaded on demand, without further interaction with the user. If the user clicks a link that contains an applet, the applet will be automatically downloaded and run in the browser.
The creation of the Applet changed internet programming because it expanded the universe of objects that can move about freely in the cyberspace. In general, there are two very broad categories of objects that are transmitted between the server and the client: passive information, and dynamic, active programs. For example, when you read your email, it is a passive data, and when you download a program, it is still a passive data, until you execute it.
The applet is dynamic, self-executing program. As desirable as dynamic, network programs are, they also present serious problems in the areas of security and portability.
As you are likely aware, every time you download a “normal” program, you are taking a risk, because the code you are downloading might contain a virus which might gather private information such as credit card number from your computer’s local file. In order for Java to be downloaded and executed on the client computer safely, it was necessary to prevent an applet from launching such an attack. Java achieved this protection by confirming an applet to the Java execution environment and not allowing it to access to other parts of computer.
Portability is the major aspect of the Internet because there are many type of computers and operating systems connected to it. The same code must work on all computers. The same mechanism, that helps to ensure security, also helps to ensure portability.
Java’s Magic: The Bytecode
The key that allows Java to solve both the security and the portability problems just described is the output of a Java compiler is not executable code. Rather it is bytecode. It is a highly optimized set of instructions designed to be executed by the Java run-time system known as the Java Virtual Machine (JVM). The execution of bytecode by JVM is the easiest way to create truly portable and secure programs. Since, it has been highly optimized, the use of bytecode enables the JVM to execute programs much faster than you might expect.
Servlets: Java on the Server Side
Applets are one half of the client/server equation. Not long before the initial release of Java, it became obvious that Java would be useful on the server side. The result was the servlet. A servlet is a small program that executes on the server. Servlets are used to create dynamically generated contents that are then served to the client.
For example, an online store might use a servlet to look up the price for an item in a database. The price informations then used to dynamically generate a web page that is sent to the browser. Because servlets are compiled into bytecode and executed by the JVM, they are highly portable.