0% found this document useful (0 votes)
2 views

Lecture-2

Java is a versatile programming language developed by James Gosling in 1995, known for its capability to run on various platforms with the principle of 'write once, run anywhere.' It supports four types of applications: standalone, web, enterprise, and mobile, and includes several editions such as Java SE, EE, and ME. The document also covers installation procedures, popular IDEs, and the phases of Java program execution, including compiling, loading, and executing bytecode.

Uploaded by

malikumarali45
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lecture-2

Java is a versatile programming language developed by James Gosling in 1995, known for its capability to run on various platforms with the principle of 'write once, run anywhere.' It supports four types of applications: standalone, web, enterprise, and mobile, and includes several editions such as Java SE, EE, and ME. The document also covers installation procedures, popular IDEs, and the phases of Java program execution, including compiling, loading, and executing bytecode.

Uploaded by

malikumarali45
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Introduction to JAVA

Rizwan Rashid
About Java
• Java is a powerful and versatile programming
language for developing software running on
mobile devices, desktop computers, and servers
• Developed by James Gosling in 1995
• Popular because of write a program once and run
it anywhere
• Java is a programming language and a platform
• Platform: Any hardware or software environment
in which a program runs, is known as a platform.
Since Java has a runtime environment (JRE) and
API, it is called a platform.
Types of Java Applications
• Four types of applications that can be created
using Java programming
– Standalone Application
– Web Application
– Enterprise Application
– Mobile Application
JDK Editions

• Java Standard Edition (Java SE)


• Java Enterprise Edition (Java EE)
• Java Micro Edition (Java ME)
JDK Versions
• History of JDK version
– https://en.wikipedia.org/wiki/Java_version_history
• Latest is Java SE 21[Java SE 21]
• Download from:
– https://www.oracle.com/java/technologies/downloa
ds/#jdk20-windows
Installing Java
• To check if Java is installed (open command
prompt and type following command)
java –version
• Setting Java Path
– Temporary Path
• Open the command prompt
• Copy the path of the JDK/bin directory
• Write in command prompt: set path=copied_path
– Permanent Path using Environment Variables
Settings
Environment Variable
• Go to "System Properties" (Can be found on Control Panel
> System and Security > System > Advanced System
Settings)
• Click on the "Environment variables" button under the
"Advanced" tab
• Then, select the "Path" variable in System variables and
click on the "Edit" button
• Click on the "New" button and add the path where Java is
installed, followed by \bin. By default, Java is installed in
C:\Program Files\Java\jdk-15\bin
Then, click "OK", and save the settings
• At last, open Command Prompt (cmd.exe) and type java -
version to see if Java is running on your machine
Popular Java IDEs
• NetBeans
• Eclipse
• IntelliJ
JDK, JRE, and JVM
• Java Virtual Machine (JVM)
– Provides a platform-independent way of executing Java source
code
– JVM comes with JIT(Just-in-Time) compiler that converts Java
source code into low-level machine language
• Java Runtime Environment
– Set of software tools which are used for developing Java
applications
– Contains JVM
– JRE = JVM + rt.jar (lang, util, awt, swing, math packages)
• Java Development Tool kit (JDK)
– Software development environment which is used to develop
Java applications
– Physically exists
JDK, JRE, and JVM
Interpreting/Compiling Source Code
• A program written in a high-level language is
called a source program or source code
• A source program must be translated into
machine code for execution
Compiling Source Code
A compiler translates the entire source code into a
machine-code file, and the machine-code file is
then executed
Interpreting Source Code
An interpreter reads one statement from the
source code, translates it to the machine code or
virtual machine code, and then executes it right
away
Creating, Compiling, and
Running Programs
Java Program Phases
• Phase 1: Creating a Program

• Phase 2: Compiling a Java Program into Bytecodes

– Bytecodes are executed by the JVM


Java Program Phases
• Phase 3: Loading a Program into Memory
– JVM class loader takes the .class file (along with
associated class files provided by Java) and loads
in memory
Java Program Phases
• Phase 4: Bytecode Verification
– Java enforces strong security to make sure that Java
programs arriving over the network do not damage your
files or your system (as computer viruses and worms
might).
Java Program Phases
• Phase 5: Execution
– Interpreter
• JVM execute bytecode using interpreter (one bytecode at a time) which
slows execution
– Just In Time(JIT) Compiler
• JVM analyzes the bytecodes as they’re interpreted searching for hot
spots — parts of the bytecodes that execute frequently
• For these part JIT also known as Java HotSpot compiler
– Translates the bytecodes into the underlying computer’s machine language

You might also like