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

01-Java Introduction

Java is a class-based, object-oriented programming language developed by James Gosling in 1991, known for its platform independence through the Java Virtual Machine (JVM). It features key principles of object-oriented programming, is simple and robust, and supports multithreading. The document also explains the differences between JDK, JRE, and JVM, highlighting their roles in Java development and execution.

Uploaded by

psudeep445
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)
2 views6 pages

01-Java Introduction

Java is a class-based, object-oriented programming language developed by James Gosling in 1991, known for its platform independence through the Java Virtual Machine (JVM). It features key principles of object-oriented programming, is simple and robust, and supports multithreading. The document also explains the differences between JDK, JRE, and JVM, highlighting their roles in Java development and execution.

Uploaded by

psudeep445
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

References :

1. [Link]
2. [Link]

[Link]

Java – Introduction to
Programming Language

Introduction to Java
JAVA was developed by James Gosling at Sun Microsystems Inc in the
year 1991, later acquired by Oracle Corporation.

Java is a class-based, object-oriented programming language and is designed


to have as few implementation dependencies as possible. A general-purpose
programming language made for developers to write once run anywhere that
is compiled Java code can run on all platforms that support Java.

How does Java achieve WORA – Write Once Run Anywhere?


Java applications are compiled to byte code that can run on any Java Virtual
Machine.

Let’s talk about JVM:

Java Virtual Machine(JVM): This is generally referred to as JVM. There are


three execution phases of a program. They are written, compile and run the
program.
● Writing a program is done by a java programmer like you and me.
● The compilation is done by the JAVAC compiler which is a primary
Java compiler included in the Java development kit (JDK). It takes
the Java program as input and generates bytecode as output.
● In the Running phase of a program, JVM executes the bytecode
generated by the compiler.
the function of Java Virtual Machine is to execute the bytecode produced by
the compiler. Every Operating System has a unique JVM implementation but
the output they produce on the execution of bytecode is the same across all
the operating systems. This is why Java is known as a platform-independent
language.

How did Java become so popular and why is it still the default language
to use for various applications?

Platform Independent: Compiler converts source code to bytecode and then


the JVM executes the bytecode generated by the compiler. This bytecode can
run on any platform be it Windows, Linux, macOS which means if we compile
a program on Windows, then we can run it on Linux and vice versa.

Object-Oriented Programming Language: Organizing the program in the


terms of collection of objects is a way of object-oriented programming, each of
which represents an instance of the class.
The four main concepts of Object-Oriented programming are:
● Abstraction
● Encapsulation
● Inheritance
● Polymorphism

Simple: Java is one of the simple languages as it does not have complex
features like pointers, Explicit memory allocation, etc.

Robust: Java language is robust which means reliable. It is developed in


such a way that it puts a lot of effort into checking errors as early as possible,
that is why the java compiler is able to detect even those errors that are not
easy to detect by another programming language. The main features of java
that make it robust are garbage collection, Exception Handling, and memory
allocation.

Multithreading: Java supports multithreading. It is a Java feature that allows


concurrent execution of two or more parts of a program for maximum
utilization of CPU.

Portable: As we know, java code written on one machine can be run on


another machine.
Write Once Run Anywhere: As discussed above java application generates
a ‘.class’ file which corresponds to our applications(program) but contains
code in binary format. It provides ease t architecture-neutral ease as bytecode
is not dependent on any machine architecture.

Please don’t worry if you don’t get the value provided by Java. Once you start using multiple
programming languages on production level, you will understand the importance of the above
points in time. Java as a programming language has withstood the test of time and that itself
is a big deal.

Installing Java
Installing Java is quite straightforward. Please install the latest version.

Differences between JDK, JRE and JVM

JDK – is for developers who want to write their own code and develop programs in Java.

Java Development Kit (JDK) is a software development environment used


for developing Java applications and applets. It includes the Java Runtime
Environment (JRE), an interpreter/loader (Java), a compiler (javac), an
archiver (jar), a documentation generator (Javadoc), and other tools needed in
Java development.

JDK (Java Development Kit) is a Kit that provides the environment to develop
and execute(run) the Java program. JDK is a kit(or package) that includes
two things
● Development Tools(to provide an environment to develop your java
programs)
● JRE (to execute your java program).

JRE:

we need an environment to make a run of our program.


Henceforth, JRE stands for “Java Runtime Environment” and may also be
written as “Java RTE.” The Java Runtime Environment provides the minimum
requirements for executing a Java application; it consists of the Java Virtual
Machine (JVM), core classes, and supporting files.
Basically, JRE is a subset of JDK required to run the java files but it doesn’t support
building new programs in Java.

In Javrs, with decimals, such as 19.99 or -19.99

char - stores single characters, such as 'a' or 'B'. Char values are surrounded by single
quotes

boolean - stores values with two states: true or false

JRE (Java Runtime Environment) is an installation package that provides an


environment to only run(not develop) the java program(or application)onto
your machine. JRE is only used by those who only want to run Java programs
that are end-users of your system.
JVM (Java Virtual Machine) is a very important part of both JDK and JRE
because it is contained or inbuilt in both. Whatever Java program you run
using JRE or JDK goes into JVM and JVM is responsible for executing the
java program line by line, hence it is also known as an interpreter.

Consider a java source file saved as ‘[Link]’. The file is compiled into
a set of Byte Code that is stored in a “.class” file. Here it will be
“[Link]“.

ADVANCED – skip for ppt:

JVM Memory
1. Method area: In the method area, all class level information like
class name, immediate parent class name, methods and variables
information etc. are stored, including static variables. There is only
one method area per JVM, and it is a shared resource.
2. Heap area: Information of all objects is stored in the heap area.
There is also one Heap Area per JVM. It is also a shared resource.
3. Stack area: For every thread, JVM creates one run-time stack which
is stored here. Every block of this stack is called activation
record/stack frame which stores methods calls. All local variables of
that method are stored in their corresponding frame. After a thread
terminates, its run-time stack will be destroyed by JVM. It is not a
shared resource.
4. PC Registers: Store address of current execution instruction of a
thread. Obviously, each thread has separate PC Registers.
5. Native method stacks: For every thread, a separate native stack is
created. It stores native method information.

You might also like