Purpose Of Java Compiler Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

The Java compiler (javac) is the component of the Java Developers Kit used to transform Java source code files into bytecode executables that can be run in the Java runtime system.e Java compiler process Java source code files and create executable Java bytecode classes. Executed bytecode class files have the extension .class, and they describe a Java class.

Java class files are created on a one-to-one basis with the classes defined in the source code. that is to say, the Java compiler generates absolutely one .class file for each class you create.

A system running compiled Java requires less memory than a conventional Java implementation. By eliminating the runtime interpreter and reducing the need for certain parts of the Java runtime, the overall size of the environment is reduced. Further more, because there is no need for on-the-fly interpretation of Java bytecode, the compiler can perform code-size optimizations without having a performance penalty

As the performance is conerned, compiled Java runs many times faster than its interpreted counterpart. In addition, because compiled code can be optimized without influencing performance, the compiler can perform speed optimizations at compile-time.

Debug Information

Another key feature of Java compiler is to generate all debugging information, including local variables. By default, only line number and source file information is generated.

This option let examine local, class instance, and static variables when debugging. One

can still set breakpoints and step through the code (Breakpoints are manually specified positions in the code where one can stop program execution)

The javac generate debugging information, specified by a comma separated list of keywords. Valid keywords are:


Source file debugging information


Line number debugging information


Local variable debugging information

Java Program Execution Steps

Java program normally go through five phases. These are

1. Edit,

2. Compile

3. Load

4. Verify

5. Execute


The editing a file include writing a java program using a program editor. Java program file name ends with a .java extension.

On Windows platform, notepad is a simple and commonly used editor java integrated development environments (IDEs) such as NetBeans, Borland JBuilder, JCreator and IBM’s Ecllipse hava built- in editors that are easily integrated into the programming environment.

Compile :

A program has to be converted to a form the Java VM so that it can interpret and run the program. Compiling a Java program is take place by converting a program file (also called source code) in to bytecodes, which are platform-independent instructions for the Java VM. The Java compiler is invoked at the command line on Unix and DOS shell operating systems as follows:

javac Program.java

On successful compilation of the program, a file with .class is produced. This is the file containing the bytecodes that will be interpreted during the execution phase.


The program must first be loaded in memory before it can be executed. This is done by the class loader, which takes the .class file containing the bytecodes and transfers it to memory. Applications (Programs) are loaded into memory and executed using the java interpreter via the command java.


Before the byte codes are executed by the java interpreter, they are verified by the bytecode verifier. This ensures that the byte codes for class that are loaded form the internet should not harm the files and system


Once program successfully compiles into Java bytecodes, it can be interpret and run on any Java VM. Interpreting and running a Java program means invoking the Java VM byte code interpreter, which converts the Java byte codes to platform-dependent machine codes so that computer can understand and run the program.


Java program is broadly divided into four parts

Methods name


Method body

Return type

Method name:

Method names must start with a lowercase letter. Method names are typically verbs, whereas variable names are usually nouns.


Parameters are enclosed in parentheses follow by the method name. They are also called formal parameters). The type of each parameter is specified before the name (eg, double). Method may have zero or more parameters, they must be separated by commas. Parameters are local variables that only present inside the method. Parameters are assigned initial values from the arguments when the method is called

Method body:

The body of a method is the statements which are executed when the method is called are enclosed in braces following the method header. Additional local variables may be defined inside the method body.

Return Type:

A method returns to the main (from where it is invoked) after it has done what it wants. Any method declared void doesn't return a value; it does not need to contain a return statement. If the method returns a value, it must contain a return statement that specifies a value to return. The data type of the return value may be primitive or object type and must match the method's declared return type. When execution reaches the return statement, control transfers back to the calling method, passing a return value to it.

Data Types In Java

A data type is a classification of data, which can store a particular type of information. Data types are basically used in computer programming, in which variables are created to store data. Each variable is assigned a data type that determine what type of data the variable may contain. We can classify the data types in to two categories

Primitive data types

Non Primitive data Type

Primitive data types are predefined types of data, which are provided by the programming language. Primitive types are also known as built-in types or basic types. Java provides more data types than just primitives. The primitive data types are:







A data type that is a non-primitive is a reference data type and are not defined by the programming language. They are references to objects as they reference a memory location.

Some examples are:








Primitive types are second-class types because in primitive inheritance is not applicable

Inheritance is one of the key feature of java which is a way to form new classes inherit attributes and behaviour of the pre-existing classes.

Java primitive types have well-defined standard sizes, so all primitive values can be stored in a fixed amount of memory between one and eight bytes, depending on the type.

As the objects, do not have a standard size, and they often require a substantial amount of memory, Java also automatically regain that memory for reuse when it is no longer needed. It does this by a process called garbage collection

Primitive data types cannot be instantiated

Non primitives can be instantiated

A primitive data type is a type where the VALUE of the variable is stored to the variable name

A reference type is a type where a REFERENCE of the object is stored in the memory.

When a primitive is pass to a method, it passes a copy of the variable.

When Object is pass to a method its actually passes a references (remote) to the method.

Predicted Output Of Code Fragment:


Program to calculate income tax


Sun Java online tutorial: http://java.sun.com/docs/books/tutorial/java/index.html











http://ic2.epfl.ch/doc/java/jdk1.2.1/docs/tooldocs/solaris/javac.html http://java.sun.com/j2se/1.4.2/docs/tooldocs/windows/javac.html