+ All Categories
Home > Engineering > 1 java intro

1 java intro

Date post: 14-Feb-2017
Category:
Upload: abdullah-al-mahamud-rosi
View: 23 times
Download: 0 times
Share this document with a friend
28
Course Title: Programming with Java
Transcript
Page 1: 1 java intro

Course Title: Programming with Java

Page 2: 1 java intro

What is Java?• Java is a general-purpose computer programming

language that is concurrent, class-based, object-oriented,

and specifically designed to have as few implementation dependencies as possible.

• It is intended to let application developers "write once, run anywhere" (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.

• Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.

Page 3: 1 java intro

Major features

• Designed by : James Gosling and Sun Microsystems. The language was initially called Oak after an oak tree .

• Developer : Oracle Corporation• Stable release : Java Standard Edition 8 Update 60

(1.8.0_60) / August 18, 2015• Implementation language: C and C++• OS : Cross-platform (multi-platform)• Filename extensions: .java , .class, .jar (Java Archive)

Page 4: 1 java intro

WORA/ WORE• "Write once, run anywhere" (WORA), or sometimes write

once, run everywhere (WORE)• Ideally, this means Java can be developed on any device,

compiled into a standard bytecode and be expected to run on any device equipped with a Java virtual machine (JVM).

• The installation of a JVM or Java interpreter on chips, devices or software packages has become an industry standard practice.

• This means a programmer can develop code on a PC and can expect it to run on Java enabled cell phones, as well as on routers and mainframes equipped with Java, without any adjustments.

Page 5: 1 java intro

What is Bytecode in Java ?• Bytecode is nothing but the intermediate representation of Java

source code which is produced by the Java compiler by compiling that source code.

• This byte code is an machine independent code.• It is not completely a compiled code but it is an intermediate code

somewhere in the middle which is later interpreted and executed by JVM.

• Bytecode is a machine code for JVM.• But the machine code is platform specific whereas bytecode is

platform independent that is the main difference between them.• It is stored in .class file which is created after compiling the source

code.

Page 7: 1 java intro

Java applet

• An applet is a special kind of Java program that is designed to be transmitted over the internet and automatically executed by a Java compatible web browser.

• A Java applet is a small application which is written in Java and delivered to users in the form of bytecode.

• The user launches the Java applet from a web page, and the applet is then executed within a Java Virtual Machine (JVM) in a process separate from the web browser itself.

Page 8: 1 java intro

Java applet

• A Java applet can appear in a frame of the web page, a new application window, Sun's AppletViewer, or a stand-alone tool for testing applets. Java applets were introduced in the first version of the Java language, which was released in 1995.

• Java applets can be written in any programming language that compiles to Java bytecode. They are usually written in Java, but other languages such as Jython,JRuby,Pascal,Scala, or Eiffel (via SmartEiffel) may be used as well.

Page 9: 1 java intro

Principles

There were five primary goals in the creation of the Java language:

• It must be "simple, object-oriented, and familiar".• It must be "robust and secure".• It must be "architecture-neutral and portable".• It must execute with "high performance".• It must be "interpreted, threaded, and dynamic".

Page 10: 1 java intro

Java Buzzwords• Simple• Secure• Portable• Object oriented• Robust• Multithreaded• Architecture neutral• Interpreted• High performance• Distributed• Dynamic

Page 11: 1 java intro

Java Buzzwords

• Simple:•Easy to learn •Easy to write programs using Java •More expressive. •Most of the complex or confusing features in C++ are removed in Java like pointers etc..

Page 12: 1 java intro

Java Buzzwords

• Secure:•Java provides data security through encapsulation. •Also we can write applets in Java which provides

security. •An applet is a small program which can be downloaded from one computer to another automatically. •There is no need to worry about applets accessing the system resources which may compromise security.

Page 13: 1 java intro

Java Buzzwords

• Portable:•Applications written using Java are portable in the sense that they can be executed on any kind of computer containing any CPU or any operating system. •When an application written in Java is compiled, it generates an intermediate code file called as “bytecode”. •Bytecode helps Java to achieve portability.

Page 14: 1 java intro

Java Buzzwords

• Object - Oriented:•Java follows object oriented model. •So, it supports all the features of object oriented model like: Encapsulation Inheritance Polymorphism Abstraction

Page 15: 1 java intro

Java Buzzwords

• Robust: •A program or an application is said to be robust(reliable) when it is able to give some response in any kind of context. •Some of those features are: 1. Type checking2. Exception handling

Page 16: 1 java intro

Java Buzzwords

• Multithreaded: •Java supports multithreading which is not

supported by C and C++. •A thread is a light weight process. •Multithreading increases CPU efficiency. •A program can be divided into several threads and each thread can be executed concurrently or in parallel with the other threads. •Real world example for multithreading is computer. While we are listening to music, at the same time we can write in a word document or play a game.

Page 17: 1 java intro

Java Buzzwords

• Architecture - Neutral: •Bytecode helps Java to achieve portability. •Bytecode can be executed on computers having any kind of operating system or any kind of CPU. •Since Java applications can run on any kind of CPU, Java is architecture – neutral.

Page 18: 1 java intro

Java Buzzwords

• Interpreted and High Performance:•In Java 1.0 version there is an interpreter for executing the bytecode. As interpreter is quite slow when compared to a compiler, java programs used to execute slowly. •After Java 1.0 version the interpreter was replaced with JIT(Just-In-Time) compiler. •This enhances the program performance means it executes rapidly.

Page 19: 1 java intro

Java Buzzwords

• Distributed: •Java supports distributed computation using Remote Method Invocation (RMI) concept. •The server and client(s) can communicate with one another and the computations can be divided among several computers which makes the programs to execute rapidly. •In distributed systems, resources are shared.

Page 20: 1 java intro

Java Buzzwords

• Dynamic: •The Java Virtual Machine(JVM) maintains a lot of runtime information about the program and the objects in the program. •Libraries are dynamically linked during runtime. •So, even if you make dynamic changes to pieces of code, the program is not effected.

Page 21: 1 java intro

How Java achieved Platform Independency ?

Page 22: 1 java intro

How Java achieved Platform Independency ?

• Java achieved platform independency by moving machine language generation from compilation phase to execution phase by introducing bytecodes and JVM.

Page 23: 1 java intro

How Java achieved Platform Independency ?

Page 25: 1 java intro

What is the most important feature of Java?

• Java is a platform independent language. This is most important feature of Java language. Platform independent language means programs written in Java will work on any computer that has Java installed on it, regardless of operating system.

• Whereas Multithreading, AWT and Event Handling, Networking, Database Connection are important features of java.

Page 26: 1 java intro

Types of Java Software• Java software is divided into two sub products

• 1) jdk (Java Development Kit)• 2) jre (Java Run time Environment)

• jdk has both "Compiler + JVM"• jre has only "JVM" • JVM is a sub-part of jre and jre is a sub-part of jdk. So in order

to run any java application jre software is sufficient but if we need to compile and execute the java program we have to install jdk software.

Page 27: 1 java intro

Types of Java Software

This diagram shows the difference between jdk,jre and JVM.

Page 28: 1 java intro

Thanks for your patience.


Recommended