about the java java technology is both a programming language and a platform –the java...

20
About the Java Java technology is both a programming language and a platform The Java Programming Language A high-level language that can be characterized as: Simple Object oriented Distributed Interpreted Multithreaded Robust Secure Architecture neutral Portable High performance Dynamic

Upload: corey-collins

Post on 27-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

About the Java Java technology is both a

programming language and a platform – The Java Programming Language

A high-level language that can be characterized as:– Simple– Object oriented– Distributed– Interpreted– Multithreaded– Robust– Secure– Architecture neutral– Portable– High performance– Dynamic

Page 2: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Programming Language

Simple– Language that can be programmed without

extensive programmer training. – Programmers can be productive from the

very beginning.

Object Oriented & Distributed– Java technology provides a clean and

efficient object-based development platform.

– To complex functions, network-based environments, programming systems must adopt object-oriented concepts.

– The needs of distributed, client-server based systems with the encapsulated, message-passing paradigms of object-based software.

Page 3: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Programming Language

Interpreted– Most programming languages, usually compile or

interpret a program so that they can work. – Java is a program that is both compiled and

interpreted. – Java’s compiler, translate a program into an

intermediate language called Java Bytecodes —the platform-independent codes interpreted by the interpreter on the Java platform.

Page 4: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Programming Language

Robust– Java is designed for creating highly reliable

software. – It provides extensive compile-time checking,

followed by run-time checking. – The memory management model is extremely

simple: objects are created with a new operator. – This simple memory management model eliminates

entire classes of programming errors that bedevil C and C++ programmers.

Secure– Java is designed to operate in distributed

environments, which means that security is of paramount importance.

– Java lets programmers construct applications that can't be invaded from outside.

– Applications written in Java are secure from intrusion by unauthorized code attempting to create viruses or invade file systems.

Page 5: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Programming Language

Architecture Neutral & Portable– To accommodate the diversity of operating

environments, Java compiler generates bytecodes. – Bytecodes -an architecture neutral format

designed to transport code to multiple platforms. – The same Java byte codes will run on any platform.

Page 6: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Programming Language

High Performance – Java achieves superior performance

by adopting interpreter scheme that can run at full speed without needing to check the run-time environment.

Multithreaded– Java’s multithreading capability

provides the means to build applications with many concurrent threads of activity.

Page 7: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Programming Language

Dynamic– Java are dynamic in their linking

stages. Java classes are linked only as

needed.

– New code modules can be linked in on demand from a variety of sources, even from sources across a network.

– Java interactive executable code can be loaded from anywhere.

Page 8: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

About the Java

– The Java Platform A platform is the hardware or software

environment in which a program runs. Most platforms can be described as a

combination of the operating system and hardware. – Windows – Linux – Solaris – MacOS.

The Java Platform is a software-only platform that runs on top of other hardware-based platforms.

The Java platform has two components: – The Java Virtual Machine (JVM) – The Java Application Programming

Interface (Java API)

Page 9: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Platform The Java Virtual Machine (Java VM)

– The Java VM is the base for the Java platform and is ported onto various hardware-based platforms.

The Java Application Programming Interface (Java API)– A large collection of useful and ready-made

software components, such as Graphical User Interface (GUI).

– Grouped into libraries of related classes and interfaces; these libraries are known as packages.

Page 10: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java Platform

Page 11: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

The Java PlatformEvery full implementation of the Java platform gives the following features:

– The essentials: Objects, strings, threads, numbers, input and output, data structures, system properties, date and time, and so on.

– Applets: The set of conventions used by applets. – Networking: URLs, TCP (Transmission Control Protocol), UDP (User

Datagram Protocol) sockets, and IP (Internet Protocol) addresses. – Internationalization: Help for writing programs that can be localized

for users worldwide. Programs can automatically adapt to specific locales and be displayed in the appropriate language.

– Security: Both low level and high level, including electronic signatures, public and private key management, access control, and certificates.

– Software components: Known as JavaBeansTM, can plug into existing component architectures.

– Object serialization: Allows lightweight persistence and communication via Remote Method Invocation (RMI).

– Java Database Connectivity (JDBCTM): Provides uniform access to a wide range of relational databases.

Page 12: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

To be truly considered "object oriented", a programming language should support at a minimum four characteristics:

– EncapsulationImplements information hiding and modularity

– PolymorphismThe same message sent to different objects results in behavior that's dependent on the nature of the object receiving the message

– Inheritance Define new classes and behavior based on existing classes to obtain code re-use and code organization

– Dynamic binding Objects could come from anywhere, possibly across the

network. Object could be able to send messages to others objects

without having to know their specific type. Dynamic binding provides maximum flexibility while a

program is executing

Page 13: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

Basics of Objects

Object technology is a collection of analysis, design, and programming methodologies that focuses design on modeling the characteristics and behavior of objects.

Examples of real-world objects: dog, desk, television set, bicycle.

Objects share two characteristics: – state – behavior

For example, – Dogs

state (name, color, breed, hungry) behavior (barking, fetching, and wagging tail)

– Bicycles state (current gear, current pedal cadence, two wheels,

number of gears) behavior (braking, accelerating, slowing down, changing

gears).

Page 14: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

Basics of Objects (Continue…)

Page 15: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

Basics of Objects (Continue…)– An object's behavior is defined by its Methods.– Methods manipulate the instance variables to

create new state.– An object's instance variables (data) are packaged,

or encapsulated, within the object and surrounded by the object's methods.

– Objects interact and communicate with each other by sending messages to each other.

Page 16: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

Classes– A class is not an object. – A class is a blueprint that defines how an

object will look and behave when object is created from the class specification.

Page 17: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

Inheritance– Object-oriented systems allow classes to be defined in terms of other classes.– Example:

– Mountain bikes, racing bikes, and tandems are all subclasses of the bicycle class.– The bicycle class is the superclass of mountain bikes, racing bikes, and tandems.– Each subclass inherits variable declarations and methods from the superclass.

Page 18: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Object-Oriented Programming Concepts

Inheritance (continue…)– The inheritance tree, or class hierarchy, can be as deep as needed.– Methods and variables are inherited down through the levels.– The farther down in the hierarchy a class appears, the more specialized its behavior.

Polymorphism– Subclasses can also override inherited methods.

Overriding Providing a different implementation of a method in a subclass of the class that originally defined the method.

– For example, A mountain bike with an extra set of gears will override the "change gears" method so that the rider could use those new gears.

Page 19: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

Installation

To write your program, you need:1. The JavaTM 2 Platform, Standard Edition.

Open: Oracle Java Webpage Download file: jdk-<version

number>-windows-<i586/x64>.exe Latest Version: jdk-7u25-windows-<i586 / x64>.exe Java Documentation:

jdk-7u25-apidocs.zip

2. A Text Editor. In example: Windows NotePad, Netbeans, Eclipse, etc.Netbean: Netbeans 7.3.1

3. Run the Java SDK (& Netbean) installer4. Update the PATH variable

– PATH C:\Program Files\Java\jdk1.7.0_<version>\BIN – SET CLASSPATH C: \ Program Files\Java\jdk1.7.0_<version>\LIB; C:\

<your working folder>

Page 20: About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized

First Java Program (w/o Netbean) Write it in Notepad:

public class Hello { public static void main(String[] args){

System.out.println("Hello World!"); }

} Save the code to a file (in working folder):

Example: HelloWorldApp.java Open MS. DOS Prompt Go to your working folder Compile the Java Code file with javac.exe

Example: c:\WorkDir\javac HelloWorldApp.java Run The Bytecode file with java.exe

Example: c:\WorkDir\java HelloWorldApp