Beruflich Dokumente
Kultur Dokumente
Agenda
Why Java
Java Architecture
Java Platforms
Distinctive features of java
Multi threading
Frameworks
What can do in java
Why java
Java is the most trusted language for building an enterprise level
application.
Java architecture
Java Platforms
JVM,JDK,JRE
This is important to understand JVM, JDK and
JRE.
JVM
JVM (Java Virtual Machine) is an abstract machine. It is a specification that
provides runtime environment in which java bytecode can be executed.
JVMs are available for many hardware and software platforms. JVM, JRE
and JDK are platform dependent because configuration of each OS differs.
But, Java is platform independent.
The JVM performs following main tasks:
Loads code
Verifies code
Executes code
Provides runtime environment
JVM Architecture
Cont
1) Classloader:
Classloader is a subsystem of JVM that is used to load class files.
2) Class(Method) Area:
Class(Method) Area stores per-class structures such as the runtime constant pool,
field and method data, the code for methods.
3) Heap:
It is the runtime data area in which objects are allocated.
4)Stack:
Java Stack stores frames. It holds local variables and partial results, and plays
a part in method invocation and return.
Each thread has a private JVM stack, created at the same time as thread.
A new frame is created each time a method is invoked. A frame is destroyed
when its method invocation completes.
Cont..
5) Program Counter Register:
PC (program counter) register. It contains the address of the Java virtual machine
instruction currently being executed.
6) Native Method Stack:
It contains all the native methods used in the application.
7) Execution Engine:
It contains:
A virtual processor
Interpreter: Read bytecode stream then execute the instructions.
Just-In-Time(JIT) compiler: It is used to improve the performance. JIT compiles parts of the
byte code that have similar functionality at the same time, and hence reduces the amount
of time needed for compilation. Here the term ?compiler? refers to a translator from the
instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.
Architectural natural
Simple
Platform Independent
Pure Object Oriented
Distributed
Secure
No memory pointers
Programs runs inside the virtual machine sandbox.
Array index limit checking
bytecode verifier checks classes after loading
class loader- confines objects to unique namespaces. Prevents loading a hacked
"java.lang.SecurityManager" class, for example.
security manager - determines what resources a class can access such as reading and
writing to the local disk.
Instrumentation
Socket programming
Multithreading
Powerful IO
Rich Data structure framework
Multithreading
Multitasking:
Refers to a computer's ability to perform multiple jobs
concurrently
More than one program are running concurrently, e.g., UNIX
Multithreading:
A thread is a single sequence of execution within a program
Refers to multiple threads of control within a single program
Each program can run multiple threads of control within it,
e.g., Web Browser
CPU1
CPU2
main
run
Process 1
Process 2
Process 3
GC
Process 4
Application Thread
Scheduling Threads
start()
Ready queue
Newly created
threads
Currently executed
thread
I/O operation completes
What happens when
a program with a
ServerSocket calls
accept()?
completed
section
while () { }
New Thread
Runnable
thread.start();
Dead Thread
run() method returns
Blocked
Object.wait()
Thread.sleep()
blocking IO call
waiting on a monitor
Scheduling
Preemptive Scheduling
Preemptive scheduling the thread
scheduler preempts (pauses) a running
thread to allow different threads to execute
Nonpreemptive scheduling the scheduler
never interrupts a running thread
The nonpreemptive scheduler relies on the
running thread to yield control of the CPU so
that other threads may execute
Daemon Threads
Java Frameworks
Frameworksare large bodies (usually many classes) of
prewritten code to which you add your own code to
solve a problem in a specific domain. Perhaps you could
say that the framework uses your code because it is
usually the framework that is in control. You make use of
a framework by calling its methods, inheritance, and
supplying "callbacks", listeners, or other
implementations of theObserverpattern.
Contrast to library. Although sometimes large libraries
are referred to as frameworks, this is probably not the
most common use of the term.
Popular Frameworks
Spring
Struts
Hibernate
Ibaties
JSF
Google web toolkit
Turbine
Apache commons libraries
Google
Facebook
eBay
Netflex
Amazone.com
Paypal
Walmart
Yahoo
Flicker
LinkedIn
Thank you