Introduction to Java
Shakir Hussain
Contents
What is Java?
Brief history of Java
The Java Programming Language
◦ Buzzwords
The Java Platform
Development Environment Setup
First Java Program
Terminology
2
What is Java?
High level programming language
Originally
developed by Sun Microsystems (now, Oracle),
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 Greentalk, later renamed to Oak and finally
Java
Java is a Platform
3
Brief history of Java
James Gosling
https://dzone.com/articles/a-short-history-of-java
https://www.javatpoint.com/history-of-java
4
The Java Programming Language
5
Java Language - Buzzwords
Platform Independent (architecture neutral)
◦ Write once run anywhere
Simple
◦ Small language, large libraries
Object Oriented
◦ Supports Abstraction, Encapsulation,
Polymorphism, Inheritance etc.
6
Java Language - Buzzwords..
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
7
Java Language – Buzzwords…
Portable
◦ Primitive data type size and their arithmetic
behavior are specified by the language.
◦ Libraries define portable interfaces
Distributed
◦ Libraries for network programming
◦ Remote method invocation
8
Java Language – Buzzwords….
Multithreaded
◦ Easy to create and use
Robust
◦ Strong memory mgmt.
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.
9
The Java Platform
Software-only platform that runs on top
of other hardware-based platforms.
Environment in which java program runs.
10
Setup Dev Environment
What do you need to write and run java
program?
◦ Java Development Kit (JDK)
◦ ASCII Text Editor
11
Download JDK
https://www.oracle.com/in/java/technolog
ies/javase/javase-jdk8-downloads.html
Go to the below section, download
platform specific installer
12
Install Steps
Once downloaded (e.g. Jdk-8u261-
windows-x64.exe) , click to install.
Steps for windows JDK will be shown in
next slides
13
Install Steps – 1st Window
14
Install Steps – 2nd Window
15
Install Steps – 3rd Window
16
Install Steps - 4th Window
17
Install Steps – 5th Window
18
Setup
Verify JDK and JRE on your hard disc.
Now, Set the path environment variable as
explained in next slide.
19
Setup..
20
Setup…
21
First Java Program
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)
First Java Program
Now, open command prompt, change directory to the folder where
you have saved your file.
Compile (javac Hello.java)
Run (java Hello)
Java Environment
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.
Java Environment
Class Loader
◦ Class Loader loads class files into memory.
◦ Class file can be loaded from local disc,
network or over the internet
Java Environment
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 Environment
Java Virtual Machine
◦ Translates the byte code into machine code
depending upon the underling operating
system and hardware combination. Which
later executed by processor.
Java Terminology
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
Java Terminology
Points to remember
JavaCompiler, JVM .. All are platform
dependent.
Only java class file (Bytecode) is
platform independent.
31