Date:11.11.2008 Subject:Distributed Data Processing Name:Maria Br ü ckner.

Slides:



Advertisements
Similar presentations
1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore G54PRG Programming Lecture 1 Amadeo Ascó 3 Java Programming Language.
Advertisements

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
 2005 Pearson Education, Inc. All rights reserved Introduction.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Object Orientated Programming
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Introduction to Java Kiyeol Ryu Java Programming Language.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Introduction to Java.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Java and C++, The Difference An introduction Unit - 00.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
DAT602 Database Application Development Lecture 5 JAVA Review.
Introduction to Programming Languages. Problem Solving in Programming.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Advanced Programming Collage of Information Technology University of Palestine, Gaza Prepared by: Mahmoud Rafeek Alfarra Lecture 2: Major Concepts of Programming.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Applied Computing Technology Laboratory QuickStart Java Learning to Program in Java Dr. Tom Way October 21, 2005.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Object Oriented Programming Lecture 2: BallWorld.
Java and C# - Some Commonalities Compile into machine-independent, language- independent code which runs in a managed execution environment Garbage Collection.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
Applications Active Web Documents Active Web Documents.
Object Oriented Programming in
Lecture 1b- Introduction
Before You Begin Nahla Abuel-ola /WIT.
Chapter 1 Introduction to Computers, Programs, and Java
Internet and Java Foundations, Programming and Practice
Data types and variables
Java programming lecture one
(Computer fundamental Lab)
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Computer Programming-1 CSC 111
M S COLLEGE ART’S, COMM., SCI. & BMS
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Date: Subject:Distributed Data Processing Name:Maria Br ü ckner

CONTENT What is Java? Characteristics Flavors Java vs. JavaScript Java Applications Java Basics Java Program Example: Hello Java! Example: Parity Calculation Garbage Collection Example: Value & Reference Inheritance What Java hasn ‘ t got

What is Java ?  programming language developed by Sun Microsystems  first public available version of Java (Java 1.0) was released 1995  target: a program can be written once and then runs on multiple operating systems  consists out of a Java compiler, the Java virtual machines, and the Java class libraries Hi, I‘m duke, the Java Mascot

Characteristics of Java  „Write once, run everywhere“  characteristics:  platform independent  OOP language  strongly-typed programming language  interpreted and compiled language  automatic memory management  single inheritance  actively developed via the Java Community Process (JCP)  watchout: Java is case-sensitive!!!

Different Flavors of Java Sun is now offering 3 “editions”:  Java Standard Edition (Java SE)  for general purpose  Java Enterprise Edition (Java EE)  Java SE plus various APIs  Java Micro Edition (Java ME)  optimized run-time environment for consumer products

Java vs. JavaScript Object Oriented Programming languages appeared in 1995 created by James Gosling of Sun Microsystem created by Brendam Eich at Netscape must be placed inside an HTML document to function can stand on its own large, complicated languagesmall, simple set of commands compiled into machine language before it can run on the web directly interpreted by Web Browsers

Architecture of Java Applications  Java applications are written as text files  java compiler creates platform independent code (bytecode)  bytecode can be executed by the java runtime environment  Java Virtual Machine is a program which knows how to run the bytecode on the operating system  JRE translates the bytecode into native code Java code is compiled to produce byte code run by Java Virtual Machine (JVM) to produce results

Java Applications in a Nutshell  Java programs written in a text files with extension “.java”  applications are.java files with a main() method  compile a Java application  javac MyProgram.java  this will result in a file of Java byte code, MyProgram.class  run a Java application  java MyProgram  the Java virtual machine will execute the program in MyProgram.class

Java Virtual Machine Windows Linux Windows JVMLinux JVM Java Application Compiler Java Source Class file (byte code)

Portability uniform run-time system Java Virtual Machine same interface on different processors interpreted “ assembly language ” Compiler generates instructions for JVM no implementation dependencies e.g. define size of types C++ int could be 32 or 64 bits in Java size of int is 32 bits on every machine

Robust simple language no “ pointers ” - no direct memory access strong typing - checked at compile time run-time bounds & cast checking exceptions automatically jump to handler code on error ensure programmer handles faults

Java Basics syntax & control structures if, for, while, do {} while () – like C++ primitive data types int, char, short, long, float, double – like C++ also byte, boolean compound data types class: e.g. to represent a person: age, name, … strings: a normal class holding characters arrays: a normal class holding a collection of items

Java Program  consists of statements  statements are processed in a certain order and / or in parallel  control structures are used to influence the processing of statements  a statement is the smallest unit which can be processed and is ended with ;

Hello Java! a simple Java program the virtual machine will start the main method of this class if called via java HelloWorld the filename must be equal to the class name the extension must be.java class HelloWorld { public static void main (String[] args) { System.out.println( „ Hello Java! “ ); }

Example: Parity Calculation to detect errors add extra “ parity ” bit to 7 data bits ensure that total number of ones is even an error will make the total odd on receipt, count the number of bits if odd, there has been at least one error if even, assume no error cannot detect even number of errors

Parity Calculation: overview // initialisation String inputData = formattedInput.readLine(); int pos = 0; int parityBit = 0; /* Calculate the parity bit */ … if (inputData.length() != 7) System.out.println("There should be 7 bits of input"); else System.out.println("Result: "+inputData+parityBit); set up using System.in a string object can tell you its length and return individual characters System.out is like count

Parity Calculation: main body while (pos < inputData.length()){ char current = inputData.charAt(pos); pos = pos+1; // current position for user (start at 1) switch (current){ case '0': break; case '1': parityBit = 1 - parityBit; // invert parityBit break; default: System.out.println("Invalid input: "+current+" at "+(pos)); } while, switch, =, if are the same as in C++

Garbage Collection memory management - major cause of bugs forget to release memory - lose resources (a leak) use memory after release - unpredictable contents release twice – confuse the memory allocator C++ explicitly release allocated memory with delete Java run-time system scans memory release blocks not referenced by program

Example: Value & Reference int x = 5; int y = 2; x = y; String Sx = new String ("five"); String Sy = new String ( “ two"); Sx = Sy y x 5 five 2 two 2 Sx Sy Garbage: can ’ t be reached from the program – could be returned to the run-time system five

Inheritance a class automatically has the methods and properties of its ancestor (base class) define new class starting from the ancestor can add data members can add methods can change implementation of methods a class always inherits from 1 ancestor Base class Child Class the child is like the base with extra facilities

What Java Hasn't Got constants use 'final' variables - can't be changed structures combine related values (e.g. name, age, address) use classes instead pointers however, objects use the reference model: a field in a object can refer to another object single byte characters all characters are Unicode (2 byte)

Summary of Java great similarities with C++ uses reference variables not pointers classes group data & functions together inheritance can define new classes by extension portability through Virtual Machine concerned with safety: garbage collection

Sources „Encyclopedia of Computer Science“ fourth edition ISBN

Thank you for attention !