0% found this document useful (0 votes)
30 views18 pages

3 Day Java Installation

Eclips installation

Uploaded by

deepak879142
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)
30 views18 pages

3 Day Java Installation

Eclips installation

Uploaded by

deepak879142
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/ 18

Introduction

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Java Installation:
For Installation:
First of all just type [download jdk] in Google and click on the first link which is oracle
Website. And select java 17 from the list and download it.

Installing Java

For Installation just double click on the .exe file.


After Successful installation JDK software gets installed in C:\ Drive.

Setting Environment Variable for Java:

There are 2 Environment variables right now for setting

1) JAVA_HOME

2) Path

To set the values for the above environment variables we need to

Right click on This PC Icon  Select properties

Select Advanced System settings

1 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Click on Environment variables as below

Go to System variables

2 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Variable Name : JAVA_HOME

Variable value : C:\Program Files\Java\jdk-17

Setting path:
Goto system variables

Select Path variable and edit

3 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

4 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Click on OK  OK  OK

Checking for java installation and version:

How to check value of OS environment Variables at command line

Ans:

set is command

 set JAVA_HOME

5 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

What is purpose of java PATH setting?

Ans:

Operating System, to identify the location of Java Software.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

First Java Program:

6 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

What happens at Compile time?

At compile time, java file is compiled by Java Compiler


[It does not interact with OS] and converts the java code into byte code.

What is ByteCode:
Byte Code is the Intermediate Code Which is only understood by the JRE and
It is stored in the .class file

Ex:

[Simple.class]

What happens at Runtime?

7 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Classloader:
is the subsystem of JVM/JRE that is used to load class files.

Bytecode Verifier:
checks the code fragments for illegal code that can violate access right to objects.

Interpreter:
It read bytecode stream then execute the instructions.

Process of Compilation & Execution:

Que:

What is the difference b/w java interpreter and just in time compiler.

Ans:
Java Interpreter and Just-In-Time (JIT) Compiler are both components of the Java Virtual
Machine (JVM) that play crucial roles in executing Java programs, but they have different
functions and purposes.

1. Java Interpreter: An interpreter is a program that reads and executes code line
by line or statement by statement. In the context of Java, an interpreter reads the
bytecode generated by the Java compiler and directly executes it on the host

8 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

machine. This means that the interpreter translates the bytecode into machine
code on the fly and executes it immediately.

2. Just-In-Time (JIT) Compiler: A JIT compiler, on the other hand, is a component


of the JVM that aims to improve the performance of Java applications. It works by
translating bytecode into native machine code just before it is executed. This
allows the JVM to take advantage of runtime information and optimize the code
for the specific host system.

The JIT compiler employs various optimization techniques, such as inlining, loop
unrolling, and dead code elimination, to generate more efficient machine code. While
the initial startup time might be slower due to the compilation process, the overall
execution performance can be significantly improved compared to interpreting
bytecode.

Que:

Why we use Notepad, if we have WordPad and MS-Word in our Computer?

Ans:-
For each and every programming language we need the text format and it is given by the text
editor (Notepad), whereas WordPad and MS-Word are not the text editor. WordPad format
is .rtf and MS-Word format is .doc / .docx.

Text format does not automatically converted or encoded.

[Program1]
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Important Points about the First prg:

Java is the purely case-sensitive language.

Comments:
With the help of the comment we can
provide the description about the program/project.

Comments are basically used for better readability.

In Java Comment is Categorized in three Category.

1) Single Line Comment

9 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

2) Multi Line Comment


3) Java Doc Comment

1) Single Line Comment //


//comment until end of line

A single-line comment begins with two slashes.


// This is my First Java Program.

2) Multi Line Comment

/*
* Multiple
* Line comment
*/

MultiLine Comment:-
A multi-line comment (Also known as a Multiple Line comment) includes anything
starting from the symbol
/* until the symbol */

People often type an asterisk (*) at the


Beginning of each line of a multiline comment to make it easier to read , but you
don’t have to (It is just a recommendation)

3) Java Doc Comment / Documentation Comment:

/**
* Java doc multiple-line comment
* This is Second Line
*/

Note-1:

Comments are ignored by the compiler

Note-2:

/* */ */ //CTE /Not Ok

We have a problem. There is an extra */ That’s not valid syntax

10 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

-->class is a keyword with the help of that we declare a class.

-->Identifier is always a name of a class, variable, methods, etc.

--> There are 67 / 51 Keywords in Java.

enum is a keyword that was introduced from the jdk 1.5.

assert is a keyword that was introduced in the jdk 1.4

const and goto are two keywords those are deprecated from the java.

Note:

In java all keywords always comes in the lower case.

In the Java programming language, a keyword is any one of 67 reserved words[1] that have a
predefined meaning in the language. Because of this, programmers cannot use keywords in some
contexts, such as names for variables, methods, classes, or as any other identifier.[2] Of these 67
keywords, 16 of them are only contextually reserved, and can sometimes be used as an identifier,
unlike standard reserved words.

Due to their special functions in the language, most integrated development environments for Java
use syntax highlighting to display keywords in a different colour for easy identification.

11 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Our program’s execution always starts from the main method.


It is known as the entry point of our program.
If we do not have the main method in our program,
in that case program would be compiled but cannot be executed.

In java, All Predefined class always start with The Capital Letter.

Ex:
String, System, etc.

So conventionally, we should also start our user-defined class name with the capital
character.

It is not a rule, it is just a recommendation.

12 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Steps of Compilation and Execution of a program

1. First of all we open the command prompt by using the


Following command [cmd]

2. Then change the drive, in which our program is stored by


using the following command.
C:\> F:
F:\>
3.Then change the directory (folder)
cd Demos

4. Then copy the address of jdk → bin folder into the path environment variable by using
the following command-

path = c:\Program-----\Java\jdk\bin

5. Compile the program by using the following command.


javac filename.java

Ex-
javac CommentDemo.java

6. Then execute the program by following command-


java ClassName

Ex:
java CommentDemo

Note:
javac and java are the executable command so they can only be executed from where they
are stored.

If we want to execute the exe (javac & java) from anywhere in the Computer, for that sake
we have to copy the address of those exe into the path environment variable.

We Can Set The Path by two ways

1) Temporary (By using Command Prompt)

2) Permanent

13 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Difference between Function & Method


The term Function represents a task whereas the term Method represents a
behavior.

When some parties authorized to perform a specific task, it becomes the behavior of
that party.

Each behavior is a task but each task is not a behavior.

void
Que:
In C or C++ return type of main can be void or int Where as in Java it can only be void.
Why?

Ans:

In C or C++ execution model is unmanaged that is OS loads the program into memory
and sits back. Hence there is a provision of exit status to let the OS know whether the
program is successfully completed or not.

In Java execution model is managed that is JRE has full control over the each
instructions hence there is no need of exit status.

14 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

static
In a class there can be of two type of members:

1) Class Member / Static Member

2) Instance Member / Object Member/ Non Static Member


Instance member/Object member represent attribute or behaviour of individual
objects where as Class member represents attributes and behaviour of the class.

By default (Implicitly) a member of a class is instance member/object member.


static keyword is used to define Class members.

Following Analogy explains the difference between class member & instance member.

India as a class has certain attributes such as Constitution, Government, Capital, Currency
etc.

It also has certain behaviours such as it trades with other countries, fight wars, makes
friends etc.
These attributes & behaviour are examples of Class members.

Each Indian as an object of class India.


Indian has some attributes such as name, age, qualification, address etc. value of these
attributes may be different for different Indians. All of these are example of Instance
members.

Class members are made available to objects but instance member are never made
available to the class.

main() method denotes the execution of a class. not the execution of any of its object i.e.
main method is a class member. Hence it is qualified by static keyword.

Command Line Argument:

Input given at the Command Prompt is called Command Line Argument.

Ex:
Let there be a class Adder to display the sum of two numbers.
This class can be defined to receive input in either of the following ways:

15 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

1) java Adder

Enter First No: 10


Enter Second No: 20

Result is: 30

2) java Adder 10 20 [Command Line Argument]


Result is: 30

Important facts about First Prg


Que:
What are System, out & println(). How they are interrelated?

System.out.println();

Ans:-
println() method is not from the System class.
It means it belongs to the PrintStream class.

System.out.println();

Note-
out is an object of PrintStream class. It is contained as a Class member/static Member of
System class.

16 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Que)
Can you save a java source file by other name than the class name?

Ans:
Yes, like the figure given below illustrates:

To compile:
javac Hard.java

To execute:
java Simple

Note:
At the time of compilation, we give the filename and at Runtime we use the class name.

Note:
But if our class is public in that case file name and class name must be same otherwise it
Would give compiler error.

17 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)
Introduction

Que:
Can you have multiple classes in a java source file?

Ans- Yes

18 DD Sir Infomatics, Agra-Whats App No. 9760433226 Online Training Courses


C,DSA,Java,Python,Web Develoment ETC… Visit www.careercompiler.com
Prepared By DD Singh,Coding Career Expert(17 Years Experience)

You might also like