0% found this document useful (0 votes)
0 views16 pages

Java introduction notes

This document introduces Java programming, explaining its significance and popularity among developers. It outlines the process of writing, compiling, and executing Java programs using an Integrated Development Environment (IDE) like Eclipse. Additionally, it provides a step-by-step guide to creating and executing a simple Java program that displays a welcome message.

Uploaded by

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

Java introduction notes

This document introduces Java programming, explaining its significance and popularity among developers. It outlines the process of writing, compiling, and executing Java programs using an Integrated Development Environment (IDE) like Eclipse. Additionally, it provides a step-by-step guide to creating and executing a simple Java program that displays a welcome message.

Uploaded by

amansin8888
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Java introduction.

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.

Have a glance at what is going on in the Java world.


Java envirnment
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 of binary 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.
java installation

Youwill now start the journey of learning programming using Java. To start
writing programs in Java, you need to first install Java.

Please follow the below steps to check whether Java is installed on your
computer.

Open command prompt and check if Java is installed in your computer using
the following command

1. java -version

If Java is installed on your computer, you will get a message about the version
installed on the command prompt window as shown below:

After making sure that you have Java installed in your computer, you
then need an IDE (Integrated Development Environment) to code Java
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.
FIRST JAVA PROGRAMME
Now that you have Java and Eclipse, you can start coding programs using
Java.

Start your programming journey with a basic Java program:

1. class Welcome {
2. public static void main(String[] args) {
3. System.out.println("Hello World! Welcome to
Java Programming!");
4. }

5. }

Every programming language has a set of rules to be followed while writing


programs. This is called as syntax of the language. The above program is
written by following the syntax of Java programming language. The program
gets compiled and executed successfully if and only if it is written as per the
syntax of the language
Explation of programme content

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 System.out.println 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.
You will now execute the same program using Eclipse.

The steps given below will enable you to use Eclipse to write any program.

Step 1: Launch Eclipse and create a workspace. Workspace is the place


where your files and projects will get saved.

Step 2: Click on File -> New -> Project


Step 3: Select Java Project and click on Next.
Step 4: Enter the Project Name, use the default options for JRE and Project
layout and click on Finish.
Click on Yes if you are asked to change perspective.
Step 5: Right-click on src and select New -> Package
Step 6: Enter the Name of the package and click on Finish. A package is a
group of similar classes in Java. You will be learning packages in detail later
in the course. Here, the package is named as demo.

Step 7: Right-click on the package, select New -> Class. This will create a
new .java file where you can write your program.
Step 8: Enter the name of the class as Welcome and click on Finish.
Step 9: The .java file will open in the editor.

Copy the code given below in the .java file and save the file.
By default, Eclipse will automatically compile the .java file into a .class
file (byte code) when the file is saved.

1. package demo;
2. public class Welcome {
3. public static void main(String[] args) {
4. System.out.println("Hello World! Welcome to
Java Programming");
5. }
6. }

7.

Step 10: To execute the program, right-click on the .java file, select Run As ->
Java Application.
.
Execution of java programme

You might also like