Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.

Slides:



Advertisements
Similar presentations
Date: Subject:Distributed Data Processing Name:Maria Br ü ckner.
Advertisements

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
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.
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 Programming
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Hello, world! Dissect HelloWorld.java Compile it Run it.
Introduction to Java.
Introduction to Java Programming Language Junji Zhi University of Toronto 1.
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.
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
Introduction to Java Presented by Daniel Rosenthal Friday, November 16 th, 2007.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
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 Tavaris J. Thomas Ph.D. BNAI ZION SCIENTISTS DIVISION JOB ORIENTATION & TERMINOLOGY CLASSES Fall 2012.
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.
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.
Java ACO101: Introduction to Computer Science. The History of Java Started out as a research project at Sun Microsystems in 1991 Code named “Green” Based.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
© 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 means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
A First Simple Program /* This is a simple Java program. Call this file "Example.java".*/ class Example { // Your program begins with a call to main().
Chapter 1: Introduction Java Programming Language How the Java Virtual Machine Works (compiling, etc…) Update by: Dan Fleck Coming up: The Java Programming.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Applied Computing Technology Laboratory QuickStart Java Learning to Program in Java Dr. Tom Way October 21, 2005.
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Lecture 02. Java Virtual Machine(JVM) –set of computer software programs and data structures that use a virtual machine model for the execution of other.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
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.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
CSCI 212 Object-Oriented Programming in Java. Prerequisite: CSCI 111 variable assignment statement while loop for loop post-increment (i++) strong typing.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
Java Computer Industry Lab. 1 Programming Java Java Basics Incheon Paik.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
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.
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.
Introduction of Java Fikri Fadlillah, S.T.
Lecture 1b- Introduction
JAVA MULTIPLE CHOICE QUESTION.
Intro to ETEC Java.
Before You Begin Nahla Abuel-ola /WIT.
Unit-1 JAVA Programming.
Chapter No. : 1 Introduction to Java.
Internet and Java Foundations, Programming and Practice
1. Environment Setting Minhaeng Lee.
Programming Language Concepts (CIS 635)
Principles of Computer Programming (using Java) Chapter 2, Part 1
An Introduction to Java – Part I, language basics
Sridhar Narayan Java Basics Sridhar Narayan
(Computer fundamental Lab)
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 Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007

Java Java is a platform and a programming language Originally implemented by James Gosling, first publicly released in 1995 Defined by Java: The Java programming language The Java Virtual Machine The Java API’s (programming libraries) The various Java platforms (SE, EE, ME)

Java Terminology Java Virtual Machine (JVM) – an abstract machine architecture Java Runtime Environment (JRE) – Sun’s implementation of the JVM Java Development Kit (JDK) – Software Development Kit for Java The Java Runtime Environment and the Java Development Kit were called the Java 2 Runtime Environment and the Java 2 Development Kit from version 1.2 through version 5.0 (also called 1.5).

To program in Java… Download and install the latest Java Development Kit (JDK 6) The most recent version is Java SE 6, which was released December 11, The next release is Java SE 7 and will not be released until at least the Summer of 2008

Defining Documents The Java Language Specification, Third Edition by James Gosling, Bill Joy, Guy Steele, and Gilad Bracha (Published: 2005, ISBN: ) The Java Virtual Machine Specification, Second Edition (Published: 1999, ISBN: ) by Tim Lindholm and Frank Yellin The Java API Changes with each version

Types of Files.java – Java source code file.class – Java class file (executable binary file)

Programming in Java All Java code must be within a class and must be stored in a.java file Program.java: public class Program { }

Programming in Java There can be only one public class per source code file (.java), and it must have the same name as the source code file Program.java: public class Program { }

Programming in Java Every class defines a template for creating new variables that program’s can use. Program.java: public class Program { }

The 8 Built-In Types The types boolean, byte, short, int, long, float, double, and char are predefined by the JLS and are called the built-in types (also called primitive types) Program.java: public class Program { }

References (The 9 th Built-In Type) There is actually one more built-in type: the reference type. Reference variables can refer to any user defined type

Writing executable code Every Java program consists of one or more Java source files. Every Java program begins execution at a main method Every main method must have the following signature: public static void main(String[] args) {...}

Writing a Program Adding a main(String[]) method to the class Program: Program.java: public class Program { public static void main(String[] args) { }

Writing a Program This program will do nothing and exit. Program.java: public class Program { public static void main(String[] args) { }

Compiling from the command line To compile from the command line, type: > javac In this case: > javac Program.java

Compiling from the command line For example:

Compiling from the command line For example:

Compiling from the command line For example:

Running from the command line To run the program, type: > java In this case: > java Program Notice the absence of the.class extension

Running from the command line This program did nothing, and exited.

Variables Classes define new variable types. Example variable types are int, float, double, etc. Program.java: public class Program { public static void main(String[] args) { }

Primitive Variables To declare a variable of a primitive type, simply write the type followed by the desired variable name. Program.java: public class Program { public static void main(String[] args) { }

Primitive Variables Program.java: public class Program { public static void main(String[] args) { int myVariable; }

public class Program { public static void main(String[] args) { Program myReference; } Reference Variables Variables of a class type are called references and are declared similarly to primitive variables: Program.java:

public class Program { public static void main(String[ ] args) { int myVariable; myVariable = 5; } Variable Assignment Variables can be assigned to by using the assignment operator “=”. Program.java:

public class Program { public static void main(String[ ] args) { int myVariable = 5; } Variable Assignment An initializer is a value assigned to a variable in the same line that the variable is declared. Program.java:

Instance Variables Reference variables can only refer to one thing: instance variables. Program.java: public class Program { public static void main(String[ ] args) { Program myReference; myReference = new Program(); }

public class Program { public static void main(String[ ] args) { Program myReference; myReference = new Program(); } Instance Variables Instance variables are variables of user defined types, i.e. variables of class types. Program.java:

public class Program { public static void main(String[ ] args) { Program myReference; myReference = new Program(); } Instance Variables Instance variables are created using the new keyword. Program.java: