0% found this document useful (0 votes)
4 views6 pages

Introduction To JAVA

Java introduction

Uploaded by

gharat2106
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views6 pages

Introduction To JAVA

Java introduction

Uploaded by

gharat2106
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

INTRODUCTION TO JAVA

INTRODUCTION

What is java?

By now, you have understood how to represent algorithms in the form of pseudo-code
and flowcharts to solve the given problem. But computers cannot understand and
execute pseudo-code. To solve the given problem by computer, you need to write a
program.

A program is a collection of instructions that performs a specific task when executed


by a computer. A program must be written in a programming language. In this
course, you will learn to write programs using Java as a programming language.

Java is one of the most popular programming languages. Some statistics about Java
are given below:

 Java has been evolving since 1991 with different editions


 According to the TIOBE Programming Community Index, it has been one of the
top 5 programming languages for the past several years
 It is being used by more than 10 million developers worldwide
 More than 15 billion devices are powered by Java technology
 More than 125 million Java-based TV devices have been deployed
 97% of enterprise desktops run Java

The features and strengths of Java have made it suitable for applications throughout
the history of Internet, and it continues to do so even for modern applications.

Page 15
JAVA LANGUAGE

Amazing! The program displays the output on clicking Execute button. But wondering
how things work behind the scene?

We write programs in programming languages like Java which are called as High-
level programming languages. But computers cannot understand high-level
languages, they understand only binary language, i.e., 0's and 1's. This is the reason
that every program that we write needs to get converted into binary form for the
computer to understand.

This conversion is made possible using system software called compilers and
interpreters.

In Java, the program (source code) written by the programmer gets compiled and
converted into byte code (compiled code) by the Java compiler.

All the byte codes required for the program are then given to the interpreter. The
interpreter reads the byte code line by line, converts it to binary form, also called as
machine language or binary language, and then executes it.

This process requires some support and an environment for the execution to
happen. JDK (Java Development Kit) helps in this for execution of a Java program. It
provides library support and Java Runtime Environment (JRE), the environment for
developing and executing Java based applications and programs.

An IDE is a software application that is required to write, execute and test


programs. There are various IDEs that can be used to write Java programs. In this
course, you will use Eclipse IDE.

Page 16
Understanding the Program:

Let us try to understand the given Java program now.

The program displays a message - 'Hello World! Welcome to Java Programming!'.


Here are some of the syntax rules of Java language:

1. The message is displayed using [Link] which is used for


displaying messages or output in Java.
2. Every statement in Java program must end with semicolon (;).
3. Every statement in Java must be present inside a method. A method is a block
of code that performs a particular task.
4. In the code given above, the method is named as main. Every program in Java
must have a main method as the code execution starts from the main method.
5. The method is defined using curly braces ({}). { signifies the start of a code block
and } signifies its end.
6. Every method in Java must be present inside a class. In the code given above,
the class is named as Welcome. You will learn about classes and methods in
detail later in the course.
7. Java is a case-sensitive programming language. E.g. - The word class should
be written in lower case.

Page 17
JDK IN DETAIL

The development, compilation and execution of Java programs is taken care by JDK
which contains 2 main components: Development tools and JRE.

Let us first discuss about development tools. The development tools consist of Java
compiler and Java launcher.

 Java compiler ([Link]) - It is the primary Java compiler. The compiler


accepts Java source code and produces Java bytecode conforming to the Java
Virtual Machine Specification (JVMS).
 Java launcher ([Link]) - It helps in launching a Java application during
execution.

Next, let us discuss about Java Runtime Environment (JRE).

The Java Runtime Environment (JRE) contains Java Virtual Machine (JVM) and the
Java standard library (Java Class Library).

 Java Virtual Machine (JVM) - It is the virtual machine that enables the computer
to run Java programs.
 Java standard library (Java Class Library) - It is a set of dynamically loadable
libraries that Java applications can call at run time. Java Platform is not
dependent on a specific operating system and hence applications cannot rely
on any of the platform-native libraries. So, the Java Platform provides a set
of standard class libraries containing functions common to modern operating
systems.

By now, you would have understood the components of JDK. Next, you will see how
a Java program get executes by the computer.

Page 18
EXECUTION OF JAVA PROGRAMME

The below diagram shows various stages that a Java program goes through during
execution.

The Java source code is saved in a file with .java extension. When we compile a Java
program (.java file), .class files (byte code) with the same class names present in .java
file are generated by the Java compiler (javac). These .class files go through various
steps when we run the program as shown in the below diagram.

Page 19
PLATFORM INDEPENDENCE

If a program written on a particular platform can run on other platforms without any
recompilation, it is known as a platform independent program.

Usually larger applications are created by a team of developers. While most of them
could be working on the same operating system such as Windows, others might be
using different operating systems like Mac or Linux. In this scenario, we might have
a situation where a program written on Windows needs to be executed on Mac OS
also.

Since Java is platform independent, it is not a problem. A program written using Java
on Windows will execute without any recompilation on any other platform.

Page 20

You might also like