session-01. objective in this session you will learn : the java technology phenomenon what is java?...

50
Session-01

Upload: jewel-mcdowell

Post on 22-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Session-01

Page 2: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Objective

In this session you will learn :

The Java Technology Phenomenon

What is Java?

What is Programming Language?

What about Java Platform ?

What is File extension of Java?

What about java Compiler?

What Can Java Technology Do?

Overview of Java

History of Java & Java Version History

JDK, JRE & JVM

Main() Method & Command line arguments

Page 3: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

The Java Technology Phenomenon

Talk about Java technology seems to be everywhere, but what exactly is it?

Page 4: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Java

Java is a programming language and a platform.

Programming LanguagePlatform

Page 5: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

What is Programming Language?

Page 6: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Programming Language

A programming language is a formal constructed language designed to communicate

instructions to a machine, particularly a computer.

Programming languages can be used to create programs to control the behaviour of

a machine or to express algorithms.

Say Hello

Error

Page 7: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform
Page 8: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Continue...

Say

Hello10101

10101Hello

Compiler

Interpreter

Page 9: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Programming Languages

Page 10: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Platform

A platform is an underlying computer system on which application programs can run.

Page 11: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

What about Java Platform ?

A platform is the hardware or software environment in which a program runs.

We've already mentioned some of the most popular platforms like Microsoft

Windows, Linux, Solaris OS, and Mac OS. Most platforms can be described as a

combination of the operating system and underlying hardware.

The Java platform differs from most other platforms in that it's a software-only

platform that runs on top of other hardware-based platforms.

Page 12: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Continue...

Java is cross platform in the sense that a compiled Java program runs on all

platforms for which there exists a JVM.

(This holds for all major operating systems, including Windows, Mac OS and Linux.)

.jar file can be distributed and executed on Windows systems, Mac systems, etc.

Java byte code won't need to be recompiled when you switch platforms.

C and C++ will require that the developer recompile the application before distributing

it to the target system,

But once that's done clients will be able to run without an issue.

Page 13: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

How to create cross platform application?

Write your application in Java (In .java files)

Compile your application using Eclipse or javac (into .class files)

(Optionally) Bundle your .class files in an executable (.jar file)

Page 14: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

What is File extension of Java?

.java is for the source code.

when source code gets compiled then generate .class file.

Language Extension

C .c

C++ .CPP

ASP .asp

C# .cs

PHP .php

Java .java

Page 15: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

What about java Compiler?

Each language has own Compiler.

In Java, programs are not compiled into executable files like c , c++ etc...

They are compiled into Bytecode , which the JVM then executes at runtime.

Java source code is compiled into bytecode when we use the javac compiler.

The bytecode gets saved on the disk with the file extension .class.

When the program is to be run, the bytecode is converted, using the Just-In-Time

(JIT) compiler.

The result is machine code which is then fed to the memory and is executed.

So Java has two step compilation:

To create byte-code

To create machine level code

Page 16: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Continue...

Page 17: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Java compilers

Note: The GNU General Public License (GNU GPL or GPL) is the most widely used free software license, which guarantees end users (individuals, organizations, companies) the freedoms to use, study, share (copy), and modify the software.

Page 18: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Example

Page 19: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

What Can Java Technology Do?

According to Sun, 3 billion devices run java. There are many devices where java is

currently used.

Some of them are as follows:

Page 20: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

How Will Java Technology Change My Life?

Get started quickly

Write less code

Write better code

Develop programs more quickly

Avoid platform dependencies

Write once, run anywhere

Distribute software more easily

Page 21: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Types of Java Applications

Standalone Application

Web Application

Enterprise Application

Mobile Application

Page 22: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Overview of Java

Java divided into three categories, they are

Page 23: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

J2SE

Page 24: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

J2EE

Page 25: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

J2ME

Page 26: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Evolution of Programming Languages

Page 27: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

History of Java

James Gosling, Mike Sheridan, and Patrick Naughton initiated the Java language

project in June 1991. The small team of sun engineers called Green Team.

Originally designed for small, embedded systems in electronic appliances like set-top

boxes.

Firstly, it was called "Greentalk" by James Gosling and file extension was .gt.

After that, it was called Oak and was developed as a part of the Green project.

Why Oak? Oak is a symbol of strength and choosen as a national tree of many

countries like U.S.A., France, Germany, Romania etc.

In 1995, Oak was renamed as "Java" because it was already a trademark by Oak

Technologies.

Page 28: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Why they choosed java name for java language?

The team gathered to choose a new name. The suggested words were "dynamic",

"revolutionary", "Silk", "jolt", "DNA" etc. They wanted something that reflected the

essence of the technology: revolutionary, dynamic, lively, cool, unique, and easy to

spell and fun to say.

According to James Gosling "Java was one of the top choices along with Silk". Since

java was so unique, most of the team members preferred java.

Java is an island of Indonesia where first coffee was produced (called java coffee).

Notice that Java is just a name not an acronym.

Originally developed by James Gosling at Sun Microsystems (which is now a

subsidiary of Oracle Corporation) and released in 1995.

In 1995, Time magazine called Java one of the Ten Best Products of 1995.

JDK 1.0 released in(January 23, 1996).

Page 29: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Java Version History

Page 30: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Java Platform Standard Edition 7

Page 31: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

JDK

JDK is an acronym for Java Development Kit. It physically exists. It contains JRE +

development tools.

lib BINJRE

JDK

Page 32: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform
Page 33: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

JRE

JRE is an acronym for Java Runtime Environment. It is used to provide runtime

environment. It is the implementation of JVM.

It physically exists. It contains set of libraries + other files that JVM uses at runtime.

libBIN

JVM

JRE

Other Files

Page 34: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

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:

1. Loads code

2. Verifies code

3. Executes code

4. Provides runtime environment

Page 35: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Basic Structure-1

Page 36: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Basic Structure-2

Page 37: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

JVM provides definitions for the:

Memory area

Class file format

Register set

Garbage-collected heap

Fatal error reporting etc.

Page 38: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Internal Architecture -1

Page 39: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Internal Architecture -2

For Java, JVM also contains heap and stack in runtime data area.

Objects and arrays are created on heap, method frames are pushed to stack.

One heap is shared by all threads, while each thread has its own stack.

Page 40: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Internal Architecture -3

runtime physical memory of a process.

mostly threads just map to OS threads, at which point they get their own stack, same

as any thread on the OS.

Page 41: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Example-1

Page 42: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Main() Method

main() method is starting execution block of a java program or any java program

start their execution from main method.

If any class contain main() method known as main class.

Page 43: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Understanding first java program

System.out.println() is used print statement. We will learn about the

internal working of System.out.println statement later.

Page 44: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

How many ways can we write Main Method

Page 45: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

To write the simple program in Notepad

Page 46: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Open Command Prompt

Page 47: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

In Command Prompt

To compile: javac Simple.java

To execute: java Simple

Page 48: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Command line arguments

If any input value is passed through command prompt at the time of running of

program is known as command line argument

by default every command line argument will be treated as string value and those

are stored in string array of main() method.

Page 49: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Example of command-line argument in java

Page 50: Session-01. Objective In this session you will learn : The Java Technology Phenomenon What is Java? What is Programming Language? What about Java Platform

Summary!!