Notes1 Introduction To Java
Notes1 Introduction To Java
1.1 Objectives
In this section, we will be discussing a little bit of Java history and what is Java Technology. We will also
discuss the phases that a Java program undergoes.
The original motivation for Java was the need for platform independent language that could be embedded
in various consumer electronic products like toasters and refrigerators. One of the first projects developed
using Java was a personal hand-held remote control named Star 7.
At about the same time, the World Wide Web and the Internet were gaining popularity. Gosling et. al.
realized that Java could be used for Internet programming.
A bytecode is a special machine language that can be understood by the Java Virtual Machine (JVM).
The bytecode is independent of any particular computer hardware, so any computer with a Java
interpreter can execute the compiled Java program, no matter what type of computer the program was
compiled on.
In Java, the programmer is freed from the burden of having to deallocate that memory themselves by
having what we call the garbage collection thread. The garbage collection thread is responsible for
freeing any memory that can be freed. This happens automatically during the lifetime of the Java
program.
The Class Loader is responsible for loading all classes needed for the Java program. It adds security by
separating the namespaces for the classes of the local file system from those that are imported from
network sources. This limits any Trojan horse applications since local classes are always loaded first. After
loading all the classes, the memory layout of the executable is then determined. This adds protection
against unauthorized access to restricted areas of the code since the memory layout is determined during
runtime.
After loading the class and layouting of memory, the bytecode verifier then tests the format of the code
fragments and checks the code fragments for illegal code that can violate access rights to objects.
After all of these have been done, the code is then finally executed.
The following figure describes the process of compiling and executing a Java program.
After creating and saving your Java program, compile the program by using the Java Compiler. The output
of this process is a file of Java bytecodes with the file extension .class.
The .class file is then interpreted by the Java interpreter that converts the bytecodes into the machine
language of the particular computer you are using.