Purpose Of Java Compiler Computer Science Essay

Published:

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

Source file debugging information

lines

Line number debugging information

vars

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

Edit:

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.

Load:

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.

Verify:

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

Execute:

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.

PARTS OF JAVA PROGRAM

Java program is broadly divided into four parts

Methods name

Parameters

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:

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:

byte

short

int

long

float

double

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:

String

Integer

ArrayList

Random

JFrame

Char

Boolean

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:

output

Program to calculate income tax

Refences

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

http://www.scribd.com/doc/16189946/Web-Design-Development

http://www.scribd.com/doc/8747110/Web-Design-Development-Using-Java

http://java.sun.com/developer/onlineTraining/Programming/BasicJava1/c...

http://ar.smart-mask.info/forum/sitemap/t-2382.html

http://www.planetsourcecode.com/vb/scripts/ShowCode.asp?txtCodeId=183...

http://up.botik.ru/~vadim/documents/BasicJava1/compile.html

http://www.netrino.com/Embedded-Systems/How-To/Compiled-Java

http://docs.rinet.ru/JavDev/ch9.htm

http://stackoverflow.com/questions/99302/would-it-be-useful-to-includ...

http://java.sun.com/javase/6/docs/technotes/tools/solaris/javac.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

http://trillian.mit.edu/~jc/man/javac

http://wps.prenhall.com/esm_deitel_chtp_4/0,8069,895691-,00.html

http://wps.prenhall.com/esm_deitel_chtp_4/13/3498/895691.cw/index.html

http://docs.rinet.ru/J21/ch22.htm

http://sankofa.loc.edu/savur/web/JavaIntroduction.html

http://wps.prenhall.com/esm_deitel_smalljava_6/25/6592/1687783.cw/con...

http://sourceforge.net/projects/jerichohtml/forums/forum/350025/topic...

Writing Services

Essay Writing
Service

Find out how the very best essay writing service can help you accomplish more and achieve higher marks today.

Assignment Writing Service

From complicated assignments to tricky tasks, our experts can tackle virtually any question thrown at them.

Dissertation Writing Service

A dissertation (also known as a thesis or research project) is probably the most important piece of work for any student! From full dissertations to individual chapters, we’re on hand to support you.

Coursework Writing Service

Our expert qualified writers can help you get your coursework right first time, every time.

Dissertation Proposal Service

The first step to completing a dissertation is to create a proposal that talks about what you wish to do. Our experts can design suitable methodologies - perfect to help you get started with a dissertation.

Report Writing
Service

Reports for any audience. Perfectly structured, professionally written, and tailored to suit your exact requirements.

Essay Skeleton Answer Service

If you’re just looking for some help to get started on an essay, our outline service provides you with a perfect essay plan.

Marking & Proofreading Service

Not sure if your work is hitting the mark? Struggling to get feedback from your lecturer? Our premium marking service was created just for you - get the feedback you deserve now.

Exam Revision
Service

Exams can be one of the most stressful experiences you’ll ever have! Revision is key, and we’re here to help. With custom created revision notes and exam answers, you’ll never feel underprepared again.