Java Introduction 1. Introduction to Java Programming2 Computers and Computer Languages Computers are everywhere –how many computers do you own? Computers.

Slides:



Advertisements
Similar presentations
A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News
Advertisements

Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Object Orientated Programming
IC211 Object Oriented Programming Overview of Java.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Introduction to Java Kiyeol Ryu Java Programming Language.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Introduction to Java.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
1 Building Java Programs Chapter 1: Introduction to Java Programming These lecture notes are copyright (C) Marty Stepp and Stuart Reges, They may.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Chapter 1 Coding Introduction.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Introduction to Programming Languages. Problem Solving in Programming.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
POS 406 Java Technology And Beginning Java Code
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Clement Allen, PhD Florida A&M University SUMMER 2006.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
JAVA PROGRAMMING BASICS CHAPTER 2. History of Java Begin with project Green in 1991 founded by Patrick Noughton, Mike Sheridan and James Gosling who worked.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
 Programming Language  Object Oriented Programming  JAVA – An Introduction  JAVA Milestones  JAVA Features.
Java and its Evolution. Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java Environment.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Java Basics 1 Brief History of Java and Overview of Langauge.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 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.
introductory lecture on java programming
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
การเขียนโปรแกรมภาษา จาวา Java Programming อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 1.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 1 Introduction.
Introduction to JAVA Programming
Introduction to Java Programming, 4E Y. Daniel Liang.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
JAVA PROGRAMMING Buzzwords. Simple: Less complex syntax than C++ Not as easy to design as Visual Basic Small size of interpreter.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
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.
Chapter 1 Coding Introduction.
Java™ 2 Platform Getting Started.
GC101 Introduction to computer and program
Chapter 1 Introduction to Computers, Programs, and Java
Chapter No. : 1 Introduction to Java.
Lecture 1: Introduction to JAVA
Java programming lecture one
Chapter 1 FOUNDATIONS OF JAVA
Chapter 1 Coding Introduction.
(Computer fundamental Lab)
Java History, Editions, Version Features
Introducing Java.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
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:

Java Introduction 1

Introduction to Java Programming2 Computers and Computer Languages Computers are everywhere –how many computers do you own? Computers are useful because they run various programs –program is simply a set of instructions to complete some task –how many different programs do you use in a day?

Introduction to Java Programming3 Definitions Program: A set of instructions that are to be carried out by a computer. Program execution: The act of carrying out the instructions contained in a program. –this is done by feeding the instructions to the CPU Programming language: A systematic set of rules used to describe computations, generally in a format that is editable by humans.

Java – An Introduction Programming language developed by Sun Microsystems in Originally called Oak by James Gosling Originally created for consumer electronics ( TV, VCR, Mobile Phone, etc.) Internet and Web was just emerging, so Sun turned it into a language of Internet Programming. Pure Object oriented language Java is a whole platform, with a huge library, containing lots of reusable code, and an execution environment that provides services such as  security  portability across operating systems  automatic garbage collection. 4

Need for Java Many different types of controllers with different set of CPU are used in electronic devices. The problem with C and C++ is that designed to be compiled for a specific target. An attempt to solve these problems, Gosling and others began work on a portable, platform-independent language that on a variety of CPUs under differing environments. Second force was the introduction of World wide web demand a language that could useful in creating portable application. 5

Java “White Paper” Buzzwords Simple Object Oriented - technique for programming that focuses on the data (= objects) and on the interfaces to that object. Portable & Architecture Neutral - By generating bytecode instructions, make it executable on many processors, given the presence of the Java runtime system. Interpreted - Java interpreter can execute Java bytecodes directly on any machine. Network-Savvy - Java has an extensive library of routines for coping with TCP/IP protocols like HTTP and FTP. High Performance – JIT Compiler monitor the code and optimize the code for speed. Robust - Emphasis on early checking for possible problems, later dynamic (runtime) checking, and eliminating situations that are error-prone. Multithreaded Secure - intended to be used in networked/distributed environments. Dynamic 6

Architectural Neutral & Portable Porting the java system to any new platform involves writing an java interpreter The interpreter will convert the byte code to machine level instructions 7

Object oriented Programming 8

Why OOP? Greater Reliability o Break complex Software projects into small, self-contained, and modular objects. Maintainability o Modular objects make locating bugs easier, with less impact on the overall project. Greater Productivity o By reusing the components we increase productivity Faster Design and Modelling 9

OOP Constructs' Objects – Real time entity Classes – Blue print of an object. It gives structure to the objects Inheritance – Deriving base class properties and behavior to child class Polymorphism – One object exists in different forms. Encapsulation – Hiding the irrelevant details to irrelevant entity Abstraction – Revealing the relevant details 10

Java Milestones 11 YearMilestones 1990 Sun decided to develop a software that could be used for consumer electronics. A project called Green Project created and head by James Gosling Explored Possibility of using C++, with some updates announced a new language named “Oak” 1992Demonstrate a new language to control a list of home appliances 1994 Team developed a new Web browser called “Hot Java” to locate and run applets Oak was renamed to Java. Companies such as Netscape, Microsoft announced their support for Java 1996 Java became the language for Internet Programming and General purpose OO language.

Java Applications Java is used to develop two types of application program: Stand-alone applications Web applications (applets) 12

Java Environment JDK - Java Development Kit ( Program enable users to create java applications) JRE- Java Runtime Environment ( Software to run java programs) IDE- Eclipse, Jcreator, NetBeans Setting Path MyComputer -> Environment Variables ->Advanced -> Path -> C:\Jdk1.7\bin 13

Structure of Java Program Package declaration; Import statements Class Declaration { //comments Variable declaration / definition Methods declaration and definition Main methods - // entry point of java program } 14

Sample Helloworld application /* Simple Helloworld Java application */ class test { public static void main(String[] args) { System.out.println(“Helloworld Java”); } // save it as test.java Compile : javac test.java Execute : java test Helloworld Java 15

Process of Building and Running Java Applications 16

Introduction to Java Programming17 A Picture is Worth… The Interpreter's are sometimes referred to as the Java Virtual Machines The output of the compiler is.class file

Sample Java Execution 18

Introduction to Java Programming19 More Definitions Code or source code: The sequence of instructions in a particular program. –The code in this program instructs the computer to print a message of Hello, world! on the screen. Output: The messages printed to the computer user by a program. Console: The text box or window onto which output is printed.

Java is Compiled and Interpreted 20

How different from compiled languages? 21

Introduction to Java Programming22 Compiling and Running Compiler: a program that converts a program in one language to another language –compile from C++ to machine code –compile Java to bytecode Bytecode: a language for an imaginary cpu Interpreter: A converts one instruction or line of code from one language to another and then executes that instruction –When java programs are run the bytecode produced by the compiler is fed to an interpreter that converts it to machine code for a particular CPU –on my machine it converts it to instructions for a Pentium cpu

CS305j Introduction to Computing Introduction to Java Programming23 The command line To run a Java program using your Command Prompt: change to the directory of your program cd compile the program javac Hello.java execute the program java Hello source code (Hello.java) compile byte code (Hello.class) execute output

Platform Independency 24

JVM Provides platform independent way of executing code, by abstracting differences between operating systems and CPU. JVM is Write Once-Run Anywhere(WORA) software JVM forms the larger part of JRE JVM role is to interpret the java byte code and translate the actions to OS calls. JVM is OS dependent which makes java source code to machine independent form. 25

JVM JVM is the interpreter used to convert the byte code to machine code on the fly and execute it. Byte code is optimized instruction set which independent of machine. JVM Architecture 26

JVM Advantages Enable java program run in protected environment Write once, run anywhere (one size fits all) Browser can cache the downloaded code and reuse it later 27

Input Processing import java.util public class InputDemo { Scanner in; public static void main(String[] args) { in=new Scanner(System.in); System.out.println(“Enter a value”); int i=in.nextInt(); System.out.println(“User has Entered :” + i ); } nextLine, next, nextDouble, hasNext, hasNextInt, hasNextDouble 28

Reading Input Using Console class – Java.io import java.util public class InputDemo { public static void main(String[] args) { Console con= System.Console(); String name=con.readLine(); String pass=con.readPassword(); System.out.println(“User Name : “+name +” and Password :” + pass); } 29

Introduction to Java Programming30 Another Java progr am public class Hello2 { public static void main(String[] args) { System.out.println("Hello, world!"); System.out.println(); System.out.println("This program produces"); System.out.println("four lines of output"); } The code in this program instructs the computer to print four messages on the screen.

Introduction to Java Programming31 Java terminology class: (a) A module that can contain executable code. (b) A description of a type of objects. (seen later) statement: An executable piece of code that represents a complete command to the computer. –every basic Java statement ends with a semicolon ; method: A named sequence of statements that can be executed together to perform a particular action or computation.

Introduction to Java Programming32 Syntax and syntax errors syntax: The set of legal structures and commands that can be used in a particular programming language. syntax error or compiler error: A problem in the structure of a program that causes the compiler to fail. –If you type your Java program incorrectly, you may violate Java's syntax and see a syntax error. public class Hello { pooblic static void main(String[] args) { System.owt.println("Hello, world!")_ }