Lecture 1. Introduction to Programming and Java MIT- AITI 2003.

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

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.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Introduction to Java.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
Introduction to Java Programming. Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps.
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.
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
Introduction to Java Programming CS 21a: Introduction to Computing I First Semester,
Java the UML Way version Only to be used in connection with the book "Java the UML Way", by Else Lervik and.
CS413: Java Programming language Applications Applets
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
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.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
CSE 1340 Class 3. Class 03 objectives State the difference between Machine Language vs. High Level Languages Discuss some characteristics of the Java.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
Java Applet Presented by: Feng Liu. Agenda Introduction Java Applet vs. JavaScript Steps in Creating a Java Applet Java Applet Example Do I have to write.
Lesson 36: The calculator – Java Applets. 1. Creating Your First Applet HelloWorldApp is an example of a Java application, a standalone program. Now you.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
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.
© 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
Clement Allen, PhD Florida A&M University SUMMER 2006.
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Java Programming Lecture 1 Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung University
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.
Java applets. Outline What is Java? Java Applications Java Applets Java Applets Securities Summary.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 35 – Overview of Java Web Programming Webpage:
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Mini University July, 2005 A Little Taste of Java (but don’t tell your folks) (they might think there’s caffeine involved)
Java and its Evolution. Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java Environment.
Java Basics 1 Brief History of Java and Overview of Langauge.
Your name CSCI/CMPE 3326 Object-Oriented Programming in Java Dongchul Kim Department of Computer Science University of Texas – Pan American 1.Applet.
Introduction to Programming. The Programming Process Create/Edit Program Compile Program Execute Program Compile Errors?Run-Time Errors? Source Program.
© 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.
CSI 3125, Preliminaries, page 1 Applet. CSI 3125, Preliminaries, page 2 Applet An applet is a Java program that runs in a Web browser. An applet can be.
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.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Introduction to Programming 1 1 2Introduction to Java.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Lecture 1b- Introduction
Chapter 1 Introduction to Computers, Programs, and Java
Introduction to.
Introduction to Java Dept. Business Computing University of Winnipeg
Java Applets.
Introduction CSC 111.
(Computer fundamental Lab)
Presentation transcript:

Lecture 1. Introduction to Programming and Java MIT- AITI 2003

What is a Computer Program? For a computer to be able to do anything (start up, play a song, run a word processor), it must first be given the instructions to do so. The instructions are written by humans in different computer languages like C, C++, Java, etc. The computer does not understand these languages. They must first be converted (compiled) to code that the machine can run ( )

How Are Programs Designed? Programs are written in a step by step instruction method which gets run every time you “run the program”.

For example, a program can be compared to a script for a play –A script is a set of instructions that calls for specific: Dialogue Acting directions Scenery –A program is also a set of instructions that might call for specific: Displays Commands –Additionally, a script may also produce a different looking play each time it is performed because of: Different actors Different theaters Different directors –Similarly, the same computer program can behave differently because of: Different user input Different software/hardware Different platforms

How Do Computers Interpret Code? Some programming languages are converted to machine code by a compiler and then can run anytime. However, because different platforms (PCs, Macs, Suns) interpret the same machine code differently, you must compile separately for each platform Programming Language compiler PC MAC Sun

Other programming languages only need to be compiled in one way and then an interpreter (software) on the machine converts it to the appropriate machine code. This is how Java works. Java Program compiler Java Bytecode PC MAC Sun Interpreter

Advantages: –Only need to compile once and then it works on every platform Disadvantages: –Software or drivers must be installed on the computers in order to run the programs

Welcome to Java The programming language you will learn in this course is called Java. A little background about Java: –It was developed in 1990 by Sun Microsystems engineer James Gosling for use in small appliances –Unexpectedly, its popularity grew because of its compatibility with the emerging World Wide Web.

Advantages of Java It is effective for programming on the web It is small and simple therefore making for faster programs It is secure for added protection against hacking It is portable; it can run on any machine without re-compiling

Programs in Java The most common Java programs are applications and applets. Applications are standalone programs. Applets are similar to applications, but they don't run standalone. Instead, applets adhere to a set of conventions that lets them run within a Java-compatible browser.

Writing Your First Application Open your text-editor and type the following piece of Java code exactly: class HelloWorld1 { public static void main(String[] args) { System.out.println("Hello World!"); } } Save this file as HelloWorld1.java (watch capitalization) in the following directory: C:\Java

Compiling and Running Your First Application Open the command prompt in Windows To run the program that you just wrote, type at the command prompt: cd C:\Java Your command prompt should now look like this: C:\Java> To compile the program that you wrote, you need to run the Java Development Tool Kit Compiler as follows: At the command prompt type: C:\Java> javac HelloWorld1.java You have now created your first compiled Java program named HelloWorld.class To run your first program, type the following at the command prompt: C:\Java>java HelloWorld1 Although the file name includes the.class extension, this part of the name must be left off when running the program with the Java interpreter.

You’ve created your first Java application!!

Writing Your First Applet Open your text-editor and type the following piece of Java code exactly: import java.applet.Applet; import java.awt.Graphics; public class HelloWorld2 extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 25); } } Save this file as HelloWorld2.java (watch capitalization) in the following directory: C:\Java

Compiling Your First Applet Open the command prompt in Windows To run the program that you just wrote, type at the command prompt: cd C:\Java Your command prompt should now look like this: C:\Java> To compile the program that you wrote, you need to run the Java Development Tool Kit Compiler as follows: At the command prompt type: C:\Java> javac HelloWorld2.java

Running Your First Applet In order to run your first Java applet, you must first write an HTML page that the applet will run in Open your text-editor and type the following piece of HTML code exactly: Applet HTML Page Applet HTML Page

Save this file as HelloWorld2.html (watch capitalization) in the following directory: C:\Java Finally, to run your first applet, type the following at the command prompt: C:\Java> appletviewer HelloWorld2.html You will learn more about HTML in following lectures

You’ve created your first Java applet!!