You are on page 1of 26

Introduction to JAVA

By:
Syed Luqman Quadri
Email: luqman@ieee.org
What is JAVA?

 A Programming Language.
 More Precisely an OOP Language.
 OOP stands for Object Oriented Programming
 A Technology used to develop
 Web Based Application
 Desktop Applications
 Mobile Applications
 Other embedded Programming
 And many more.
Java Version History
 JDK Alpha and Beta (1995)

 JDK 1.0 (23rd Jan, 1996)

 JDK 1.1 (19th Feb, 1997)

 J2SE 1.2 (8th Dec, 1998)

 J2SE 1.3 (8th May, 2000)

 J2SE 1.4 (6th Feb, 2002)

 J2SE 5.0 (30th Sep, 2004)

 Java SE 6 (11th Dec, 2006)

 Java SE 7 (28th July, 2011)

 Java SE 8 (18th March, 2014)

 Java SE 9 (21st Sep, 2017)

 Java SE 10 (20th March, 2018)


Java Editions:
 J2SE
 Known as Java 2 Standard Edition
 Contains Core Java
 JDBC (Java Database Backend Connectivity)
 JFC (java foundation classes)
 Etc.
 J2EE
 Known as java 2 Enterprise Edition
 Contains Advanced java
 JSP
 Servlets
 Struts, EJB, etc.
Java Editions:
 J2SE
 Known as Java 2 Standard Edition
 Contains Core Java
 JDBC (Java Database Backend Connectivity)
 JFC (java foundation classes)
 Etc.

 So basically we have three editions of JAVA-


 J2SE
 J2EE
 J2ME
Features of Java -
Features of Java -

 Object Oriented
 Object may be anything.
 And in java everything is treated as an object and that is why people
also call it purely OOPL.
 There are four pillars of OOP-
 Inheritance
 Polymorphism
 Abstraction
 Encapsulation
 This object oriented behaviour of java made it different from other
programming languages(c, c++, assembly) of that time.
Features of Java -

 Simple
 Java has included many features of C / C ++, which makes it easy to
understand.
 Secure
 The Java platform provides various features for security
 provides secure platform for developing and running applications
 automatic memory management, reduces memory corruption and
vulnerabilities
 provides secure communication by protecting the integrity and
privacy of data transmitted
Features of Java -

 platform independent
 Java was built with the philosophy of "write once, run anywhere"
(WORA). The Java code (pure Java code and libraries) you write on
one platform (operating system) will run on other platforms with no
modification.

 To run Java, an abstract machine called Java Virtual Machine (JVM) is


used. The JVM executes the Java bytecode. Then, the CPU executes
the JVM. Since all JVMs works exactly the same, the same code works
on other operating systems as well, making Java platform-
independent.
Features of Java -

 Robust
 During the development of the program, it helps us to find possible
mistakes as soon as possible.
 Portable
 Java provides us the concept of portability. Running the same program
with Java on different platforms is possible.
 Multi-Threaded
 The multithreading programming feature in Java allows you to write a
program that performs several different tasks simultaneously.
 Distributed
 Java is designed for distributed Internet environments as it manages
the various network services and protocols.
How java program works

 Java source code is written in human readable and


understandable language.
 And we all know that computer understands its own language that
is binary.
 So there must be something that converts this human
understandable language into machine understandable code.
 So this process of converting the english-like language into
machine understandable form is performed by various
components of java platform.
How java program works

 We can observe that there are two process taking place;


Compilation and Execution-
 Compiler
 Java VM

 And this is how java achieves platform independence.


 You can run compiled java code on any machine having JVM.
 So this way we are also achieving portability.
 Java platform processes the program into two phase-
 Compilation
 Execution
Diving deep into java platform

 Java platform is available in following two forms-


 JDK
 JRE

 JDK stands for Java Development Kit.


 It is used for development purpose and it contains almost all
the features of JRE.
 JRE stands for Java Runtime Environment.
 it is capable of executing programs. It contains JVM (Java
Virtual Machine).
Diving deep into java platform
Diving deep into java platform
JDK-

 JDK stands for Java Development Kit.


 It contains all the library and run-time environment required for java
development and execution of java programs.
 So to start programming in java we must have JDK installed.
 We can install it from the following link-
 http://www.oracle.com/technetwork/java/javase/downloads/index.
html
 Some important tools of JDK are-
 javac, java, javadoc, apt, appletviewer, jar, jdb, javah, javap,
extcheck
JRE-

 JRE stands for Java Runtime Environment.


 It contains all the tools required for running java application.
 So if we have JDK installed then we don’t need to install JRE
seperately.
 But if we just want to run java application then we only need JRE
and it must be installed.
 Oracle provides two flavor of JRE-
 Server JRE
 JRE
 Server JRE is used for running java applications on web servers.
JVM (Java Virtual Machine)-

 Java Virtual Machine is part of JRE.


 JVM is responsible for the following-
 Loading Byte Code
 Verification of Bytecode
 Executing the ByteCode.
 Allocating memory space.
 Java compiler produces code for this Virtual Machine.
 Its the responsibility of JVM to successfully execute the given
bytecode.
JVM Architecture-

 1. Class Loader
 The class loader is a subsystem used for loading class files. It
performs three major functions viz. Loading, Linking, and
Initialization.
 2. Method Area
 JVM Method Area stores class structures like metadata, the
constant runtime pool, and the code for methods.
 3. Heap
 All the Objects, their related instance variables, and arrays are
stored in the heap. This memory is common and shared across
multiple threads.
JVM Architecture-

 4. JVM language Stacks


 Java language Stacks store local variables, and it’s partial
results. Each thread has its own JVM stack, created
simultaneously as the thread is created. A new frame is created
whenever a method is invoked, and it is deleted when method
invocation process is complete.
 5. PC Registers
 PC register store the address of the Java virtual machine
instruction which is currently executing. In Java, each thread
has its separate PC register.
 6. Native Method Stacks
 Native method stacks hold the instruction of native code
depends on the native library. It is written in another language
instead of Java.
JVM Architecture-

 7. Execution Engine
 It is a type of software used to test hardware, software, or
complete systems. The test execution engine never carries any
information about the tested product.
 8. Native Method interface
 The Native Method Interface is a programming framework. It
allows Java code which is running in a JVM to call by libraries
and native applications.
 9. Native Method Libraries
 Native Libraries is a collection of the Native Libraries(C, C++)
which are needed by the Execution Engine.
Installing JDK:

Download the required JDK version from the oracle website-


http://www.oracle.com/technetwork/java/javase/downloads/jdk8-
downloads-2133151.html

Install it.

To Check whether it is installed correctly and working fine


Open the command prompt.
Type >> java --version
it will show the currently installed java version.
Running Program Using Command Line:

Write Your source file in a text editor and save it with an extension of .java

Now open the command prompt, and go to the directory where you have saved
your file by using cd command.

Now type
c:\\ javac <filename>.java

It will compile the code written in the text file, and will create the respective class
file.

This class file will be executed using java command as following.


c:\\ java <filename>
IDE for java-

Netbeans

Eclipse

And many more..

You might also like