Java is another technology that aims to bring interactivity to the Web and networks by dynamically distributing executable content as required. It originated from Sun Microsystems
. They were working on a language that would be cross platform capable and, at the same time, help them to propel their products in the market. They recognized its suitability as a language for embedding executable logic within an HTML page for processing by a Java enabled Web Browser. While the term Java encompasses a number of Sun owned technologies, it is frequently used to refer to the Java programming language. This distinct from JavaScript which is very loosely based on Java and C++, and is used in scripting and should not be confused with Java.http://java.sun.com/
Java is a simplified object-orientated programming language that was originally based on C++, and so looks familiar to C++ programmers. However, the Java designers removed some of the C++ features that can cause developers problems and stop code from being robust.
A Java program is compiled into Java byte code – while this is an optimized format it is not native CPU machine code. Java Byte code is executed by an interpreter called a Java Virtual Machine (JVM)which converts byte code, on the fly, into native machine code.Some JVMs include a just-in-time (JIT) compiler that speeds up the processing by keeping a copy and reusing translated codes. Alternatively, some vendors have produce native compilers that directly generate native machine code for the target platform. Like most operating system vendors, Microsoft developed a Java VM for their Windows operating systems and then licensed the name from Sun.
A Java program running in a Web Browser is called an Applet and is referenced in the HTML page with the
tag. Java applets can be anything from games, business resources, and complex multimedia effects to simple animations and scrolling logos, or even dynamic menus, such as the one featured at <APPLET>
:http://java.sun.com
A Java program running standalone is called an Application. A great advantage of a Java program is that it is portable – it can run on platforms that support the Java VM. Java is sometimes summarized as "Write Once – Run Anywhere".
A lot of effort has been made to ensure that Java Applets are safe and cannot cause malicious damage to a client machine. Typically the JVM uses the sandbox security model to ensure this doesn't happen. By sandbox we mean a model which restricts access to potentially dangerous parts of the operating system – i.e. you don't want an applet to be able to wipe your hard disk. The Microsoft JVM supports the Authenticode mechanism and allows trusted Applets the freedom to access certain system resources.
Many people question whether Java is better than ActiveX – in truth, both have their strengths and weaknesses. While many view the technologies as competing, Microsoft has embraced the idea that Java and ActiveX complement each other. The Microsoft JVM is actually an ActiveX control that can expose public variables and functions, as shown in the following diagram. This enables an Applet to co-operate with a Web Browser scripting language. Furthermore, the Microsoft JVM provides full support with COM/DCOM allowing the two different technologies to integrate seamlessly.
Microsoft's Java development tool is called Visual J++. In addition to the standard JAVA classes found in the AWT, IE4 comes with Microsoft's Application Foundation Classes (AFC) so saved the trouble of the classes having to be downloaded each time. The AFC is a set of powerful class libraries that expand upon the standard Java offerings to provide user interface capabilities that have the visual quality that Windows users are accustomed to. AFC is designed to run on all platforms supporting a JVM except for two classes that are Internet Explorer specific and are used for data binding.
It's not really appropriate to go much further into Java in this introduction as we won't be using it in the book. If you wish to know more then look out for Beginning Java, by Wrox Press ISBN 1-861000-27-8.