Prepared by Shakir Hussain
What is Java?
Why Java?
Download, Install and Setup
Java Terminology- JDK, JRE, JVM
First Java Program
Java Environment – Java Compiler, Class
Loader, Bytecode Verifier, Java Virtual
Machine
Points to remember
High level programming language
Originally developed by Sun Microsystems, Which
was initiated by James Gosling
Designed with a concept of write once and run
anywhere
First version of java released in 1995
Initial name was Oak, later renamed to Green
and finally Java
James Gosling
Platform Independent
Write once run anywhere
Simple
Small language and large libraries
Object Oriented
Supports Abstraction, Encapsulation, Inheritance, Polymorphism etc.
Auto Garbage Collection
Memory management handled by Java Virtual machine
Secure
No memory pointers, program run inside virtual machine
Java Bytecode verification
Array Index limit checking
Signed Applets
Portable
Primitive data type size and their arithmetic behavior are specified by
the language.
Libraries define portable interfaces
Multithreaded
Easy to create and use
Distributed
Libraries for network programming
Remote method invocation
Dynamic
Finding runtime type information is easy.
The linking of data and methods to where they are located, is done at
run-time.
New classes can be loaded while a program is running. Linking is done
on the fly.
Whatdo you need to write and run java
program?
Java Development Kit (JDK)
A Text Editor
Download latest version of JDK (java
development kit) from
http://www.oracle.com/technetwork/java/javase
/downloads/index.html
and install.
Use the following link for Installation instructions
(for JDK 1.7)
http://docs.oracle.com/javase/7/docs/webnotes/
install/index.html
I am going to demonstrate simple download, install
and setup of JDK 1.7 on my windows X86.
Step 1 : Visit java download page, click on
jdk
Step 2 : Accept the license
Step3 : Download the JDK for your OS (I am
downloading JDK for Windows x86) and save
on your hard drive.
Click jdk-7u17-windows-i586.exe to install
Verify JDK and JRE on your hard disc.
Now,Set the path environment variable as
explained in next slide.
C:\Program Files (x86)\Java\jdk1.7.0_17\bin
JDK : Java Development Kit
All you need to develop, compile, debug and run
your java program.
JRE : Java Runtime Environment
Subset of JDK
Includes Minimum Elements required to run java
class file
Does not contain development tools like
compiler, debugger etc.
JVM : Java Virtual Machine
Actually runs the java program and uses the
library and other supporting files provided by JRE
What do you need?
Java Development Kit (JDK)
A Text Editor
Open the notepad, write the following code
and save the file as Hello.java (Let’s say file is
saved as E:/test/Hello.java)
Now, open command prompt, change directory to the
folder where you have saved your file.
Compile (javac Hello.java)
Run (java Hello)
Compilation
Java Compiler translates the java source file into
the class file
Class file contains bytecodes, the “machine
language” of the java Virtual machine (JVM).
This java class file can run on any hardware
platform and Operating System, which hosts JVM.
Class Loader
Class Loader loads class files into memory.
Class file can be loaded from local disc, network
or over the internet
Bytecode Verifier
It verifies that the bytecodes are valid and safe.
Does not violate java security restrictions
Checks the internal consistency of the class and
validity of the code
Java Virtual Machine
Translates the byte code into machine code
depending upon the underling operating system
and hardware combination. Which later executed
by processor.
Class
Loader Java
Class
Bytecode Libraries
Java Verifier
Source
(.java)
Just in
Java
Java Time
Execution
Bytecodes Engine
Code Java
move locally Generator Virtual
or through machine
Java network
Compiler
Java Operating System
Bytecode
(.class )
Hardware
30
Java Compiler, JVM .. All are platform
dependent.
Only java class file (Bytecode) is platform
independent.