Java |
Brief DescriptionJava started out as a programming language for consumer electronics. Software for consumer electronics has some unique requirements. For example, the software needs to run on new chips as they are introduced. As prices change for computer chips, the manufacturers will switch to the now less expensive computer chip. This means the software must be platform independent. The type of software must also be extremely reliable, often when a unit fails, the consumer will demand it be replaced. [4] The Java language was originally called Oak. Oak never really caught on, yet a development team headed by James Gosling continued to work on this new programming environment. With the explosion of the Internet it was quickly realized by Sun Microsystems that Oak (now called Java) fit the Internet model quite well. Java was released in Alpha form to the Internet in 1995. [4] [5] [6] Java has been described by Sun as having the following characteristics [4] [5] [6] [7] :
FeaturesHere are the most significant features of the Java programming language: [2]
Java source code is compiled into architecture neutral bytecodes. A Virtual Machine (VM), which has to be implemented on each architecture, interprets these bytecodes. The Java Virtual Machine (JVM) takes each instruction (bytecode) and executes that instruction on the programs behalf. So a Java program does not actually execute on the CPU; instead it is executed by a "virtual" CPU. To increase execution speed of Java programs, there are also just-in-time (JIT) compilers translating the bytecodes into native platform machine code at runtime. [2] [12] Compared to C/C++, there are no pointers, no addresses, no operator overloading, no structures, no functions, no multiple inheritance, no header files and no object files to be linked together to produce an executable. Before executing bytecode in the VM, memory is laid out only after the byte codes have been verified by the Java runtime environment and security manager. These simplifications of the language and additional verifications before and during program execution lead to more robust and secure applications. [2] [6] Java ApplicationsJava applications are stand-alone programs, running in a virtual machine (not inside a Web browser). By default, every class inherits from the Object class, which supplies a basic set of methods. There is also a main method which is executed after instantiation of the object. Constructor methods can be used to initialize an object; which can be overloaded, so that different parameters to the object can cause different behavior. [2] The famous "HelloWorld" program in Java looks like [2] class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
Java also offers a native interface (JNI) to access already implemented functionality in C/C++ which helps promote reusability of legacy applications. This interface can only be used in Java applications (and not in Applets), because these functions are not written in Java. This would open a hole in the "sandbox" within browsers and would limit cross platform portability. [2] Java AppletsTo run an Applet, it has to be called from an HTML web page that can be viewed in an Appletviewer or in a Java enabled Web browser. There is a special HTML tag to run an Applet inside the HTML page: <APPLET CODE ="HelloWorld.class" WIDTH=100 HEIGHT=50> </APPLET> Unlike applications, Applets must be a subclass of java.applet.Applet. The HelloWorld program implemented as an Applet would look like this: import java.applet.Applet;
import java.awt.Graphics;
public class HelloWorld extends Applet {
public void paint(Graphics g) {
g.drawString("Hello world!", 50, 25);
}
}
Applets have more restrictions than Java applications. They have no access to the file system and they can only access the server where the Applet was loaded. For this reason, there's no possibility for an Applet to alter anything on the client's computer, like reading/writing/deleting files, or starting programs. This behavior is also known as the 'sandbox model'. The Applet is only able to play (and mess up) within the confines of the Java Virtual Machine. This makes it virtually impossible to receive a virus from a Java applet. [2] [4] |
| Return to Gerber Family Home Page |