Rina System development with Java Instructors: Rina Zviel-Girshin Interdiciplinary Center Herzlia School of the Computer Science Fall:

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

Designing a Program & the Java Programming Language
In Review JAVA C++ GUIs - Windows Webopedia.com.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Object Oriented Programming in Java George Mason University Fall 2011
Chapter 1: Introduction
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
Aalborg Media Lab 18-Jun-15 Introduction Introduction to System Design I Fall 2004.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Getting Started with Java
Sadegh Aliakbary Sharif University of Technology Fall 2011.
Your Interactive Guide to the Digital World Discovering Computers 2012.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Introduction to Java Tonga Institute of Higher Education.
Introduction to Java Programming with JBuilder 4
+ 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.
CS413: Java Programming language Applications Applets
Sadegh Aliakbary Sharif University of Technology Spring 2011.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
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.
©Xiaoying Gao, Peter Andreae First Java Program COMP 102 #2 2014T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
First Java Program COMP 102 #2 2015T2 Xiaoying Sharon Gao Computer Science Victoria University of Wellington.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
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.
Copywrite ASC1 System development with Java Instructors: Rina Zviel-Girshin Interdiciplinary Center Herzlia School of the Computer Science Fall:
© 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.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
Rina System development with Java Instructors: Rina Zviel-Girshin Interdiciplinary Center Herzlia School of the Computer Science Fall:
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Introduction to Programming. The Programming Process Create/Edit Program Compile Program Execute Program Compile Errors?Run-Time Errors? Source Program.
Introduction Mehdi Einali Advanced Programming in Java 1.
© 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.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
1 Programming Languages and Java Programming languages Java language The basic program Java syntax.
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.
CSCI-235 Micro-Computer Applications
Text by: Lambert and Osborne
Introduction to Java Dept. Business Computing University of Winnipeg
Advanced Programming Fall 2017.
Introduction CSC 111.
(Computer fundamental Lab)
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:

Rina System development with Java Instructors: Rina Zviel-Girshin Interdiciplinary Center Herzlia School of the Computer Science Fall:

Rina Information Source Course site : Course book: Java Software Solutions /Lewis & Loftus Thinking in Java / Bruce Eckle

Rina Course Methodology Non-Linearity Spiral model Hypermedia CAI – Computer Assisted Instruction Interactive learning Labs and programming Multi-approach: inductive-deductive trails

Rina Programming Languages and Java Programming languages Java language The basic program Java syntax

Rina Programming The process of writing programs called a programming. The process requires: Programming language A translator of the programming language into machine language Programs are written in programming language.

Rina Syntax Syntax describes the grammatical rules of a language. Valid words Valid grammar constructions Valid punctuation Programs must be syntactically correct.

Rina Semantics Semantics gives the meaning of what you write with a language. A programming language must precisely define the meaning of every statement that can be written with it. Programs must be semantically correct.

Rina Example The following sentence is syntactically correct but semantically incorrect. “ Java programs are green and yellow.” –All words are correct words. –Punctuation is correct. –But logically the sentence makes no sense.

Rina Programming languages There are several families of the programming languages: Procedural ( Pascal, C++, Java) Logical ( Prolog) Visual ( Visual Basic) Document (HTML, LATEX)

Rina Programming languages Procedural languages can be divided into:  Machine languages  Low-level (Assembler )  Intermediate-level (C)  High-Level (C++, Java)

Rina Java Java is high-level language. Java is object oriented language. In this course we will use the terms: – OOP, – OOA, – OOD.

Rina OOA and OOD OOA- Object-Oriented Analysis is a way to analyze a problem. OOD- Object-Oriented Design is a way to design a solution. Both see the world as: objects and their relations (behavior, communication).

Rina OOA and OOD (cont) The way to analyze a problem is to define the objects relevant to it and their behavior. The way to solve a problem is to realize the objects relevant and the behavior we need. Both are useful as preliminary stages in OOP- Object Oriented Programming.

Rina OOP Objects are the building blocks of:  the problem  the solution  the input source  the output target  the environment

Rina Objects Objects include both: data (fields, variables, state) processing (behavior, methods, functions) Objects have two kinds of behavior: outer – I/O, messages, relations with others inner – processing (usually computing the messages)

Rina Objects (cont) Relations between objects are implemented using communication (messages). Communication can have many forms. Some forms are very different from the usual idea of a message. Objects acquire structure using their relations. The structure is usually tree-like.

Rina High-level languages Writing programs in machine language is possible but very difficult and time consuming. Programs usually written in a more human readable language - high-level language. Java is high-level language. A program written in any computer language must be translated into a machine language in order to be executed.

Rina Translators Compiler A compiler is a program that translates a source program (usually high level language) into target program (usually machine language program). The resulting program can be executed many times. Interpreter An interpreter is a program that reads, translates and executes the source program statement by statement. The translation is done each time the program runs.

Rina Java Java is a high-level, third generation programming language, like C, Fortran, Smalltalk. Shares much of C's syntax. Designed by a group at Sun MicroSystems. Originally called Oak.

Rina Java advantages Platform independent “Write once, run anywhere”. Improve robustness, remove unsafe language loopholes. According to Sun: “ Java is simple, object-oriented, distributed, interpreted, robust, secure, architecture-neutral, portable, high-performance, multithread, and dynamic language.”

Rina Java disadvantages The main Java disadvantage: Efficiency concerns. Looking to the future: VM performance will improve.

Rina Java environments Java has many environments. The number grows as Java evolves. Among them are: Text applications Beans Applets GUI Applications Packages

Rina Two main environments The two main environments:  Web Browser  Operating System

Rina Web Browser In the browser environment the browser acts as an intermediate between the program and the operating system. The JVM resides inside the browser. The program can be simpler. The program has to work in graphical mode. The program is called “Applet” (a small application).

Rina Operating System In the operating system environment the program is called “application”. Application has a more rigid structure. Application can be textual or graphical. Application is less secure.

Rina Learning Java The specific challenge is twofold:  Learning the language technical aspect: the large set of new features class libraries classes methods which are provided as part of the language.  Learning to maximize the benefits of the object- oriented paradigm.

Rina OOA and OOD vs. OOP OOA is a way of analyzing - OOD is a way of thinking – OOP is a way of doing. OOA is about “why” – OOD is about “what” – OOP is about “how”.

Rina Starting to Program The basic idea of the course is to start programming as soon as possible. At first you will have to take a lot of things on trust. Promise: we will return to the details later.

Rina Java programs All Java programs have three parts: Auxiliary prescriptions A class – an envelope around the other components Code per se – Optionally – other components which include the instructions themselves Instructions to be executed

Rina Writing a Java Program Use an editor to type the program code. Save the code file. Compile the file with Java language compiler. Fix the bugs! Run the program.

Rina A basic Java Program // Prints “How are you?” to the screen class My { public static void main (String[] args) { System.out.println(“How are you?”); }

Rina A basic Java Program // Prints “How are you?” to the screen class My { public static void main (String[] args) { System.out.println(“How are you?”); }

Rina Java program structure A Java is made up of one or more classes. Classes have names. The ‘My’ program consists of one class named ‘My’.

Rina Class structure A Java class contains one or more methods. Methods have names too. The program (the class) has to have a main method. The method is called (surprisingly) – main.

Rina Main The main method has a standard syntax: public static void main(String args[]) {… // your code } There can be only one main per file. The main method contains the code to be executed when the program runs.

Rina Method structure A method contains one or more statements. The main method of My program has a single statement: System.out.println(“How are you?”);

Rina Stages of Writing and Executing Assumptions: Using only the basic JDK software Assuming the JDK was installed properly In the WIN/DOS environment Class name is My File name is My.java Directory (folder) name is c:\java

Rina Stages of Writing and Executing 1.Open a text editor that can produce a plain text file (such as Notepad). 2.Create a source code file with the extension on the file name being.java. The file has to have the same name as the outer class. 3.Start a the DOS command environment by opening MSDOS prompt (using the Start->Programs->MSDOS Prompt series of choices).

Rina Stages of Writing and Executing 4.Change directory to the directory containing the source file. 5.Compile the file, using the prompt command: javac My.java 6.The result is My.class in the same folder. 7.Run using the prompt command: java My

Rina Applets The program has to import two packages: applet.Applet awt The program (the class) has to extend the Applet class, using the following syntax: public class My extends Applet { // your code }

Rina Basic applet code The final code looks like this: import java.awt.*; import java.applet.*; public class My extends Applet { // your code }

Rina Stages of Writing and Executing Applet can’t be run directly. Applet has to be run in Browser and by the Browser. Web browser executes web pages. Web page should call the applet code.

Rina Call to applet The call to applet consist of: –the command APPLET –the name of the applet class –the dimensions of the panel in which the applet will run

Rina Example Assuming the name of the applet class is HelloWorld.class the call to applet looks like this: <APPLET CODE = "HelloWorld.class" WIDTH = 150 HEIGHT= 50>

Rina HTML The call to applet has to be in HTML file. The file can look as follows: Java applet test page <APPLET CODE="HelloWorld.class" WIDTH=150 HEIGHT=50>

Rina Execution Assuming the file is called HelloWorld.html 1.The stages common to all, described above. 2.Open the file HelloWorld.html in the Browser.

Rina Java Compiler The Java compiler is called javac. Java programs are compiled to byte code.

Rina Byte code The Java compiler translates Java program into a special representation called byte code. Java byte code is a machine code for Java virtual Machine(JVM). VM is a platform-specific tool to interpret the byte code and to translate it to commands for certain processor and OS. The use of the byte code makes Java platform independent.

Rina Compile-interpret-execute cycle

Rina Compile-interpret-execute cycle

Rina Any Questions?