Introduction to Java Tonga Institute of Higher Education.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

In Review JAVA C++ GUIs - Windows Webopedia.com.
Object Oriented Programming in Java George Mason University Fall 2011
Object Orientated Programming
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.
CENG 161 Introduction to Computer Science Instructor: Dr. Nurdan SARAN Lab Assistant: Arzu Burçak Sönmez.
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.
CS0007: Introduction to Computer Programming Setting Up Java.
Using the Java programming language compiler. Review of relevant material from previous lectures From previous lectures: A computer can only execute machine.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
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.
Parts of a Computer Why Use Binary Numbers? Source Code - Assembly - Machine Code.
CS110/CS119 Introduction to Computing (Java)
CS413: Java Programming language Applications Applets
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
 Java Programming Environment  Creating Simple Java Application  Lexical Issues  Java Class Library.
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.
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.
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
UCSC All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.
Computer Programming A program is a set of instructions a computer follows in order to perform a task. solve a problem Collectively, these instructions.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Introduction to C++ Programming Language
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
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.
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.
Lecture.1: Getting Started With Java Jiang (Jen) ZHENG May 9 th, 2005.
Getting started with Programming using IDE. JAVA JAVA IS A PROGRAMMING LANGUAGE AND A PLATFORM. IT CAN BE USED TO DELIVER AND RUN HIGHLY INTERACTIVE DYNAMIC.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
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.
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.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
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.
Java FilesOops - Mistake Java lingoSyntax
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
1 Introduction Read D&D Sec 1.8; Sec 1.13 THE Java tutorial -
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
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.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
Topic 2: Hardware and Software
Why don’t programmers have to program in machine code?
Lecture 1b- Introduction
Programming languages
Programming Language Hierarchy, Phases of a Java Program
Lecture 1: Introduction to JAVA
Java programming lecture one
Introduction to Java Dept. Business Computing University of Winnipeg
Tonga Institute of Higher Education
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Introduction CSC 111.
IB Computer Science II Paul Bui
Review of Previous Lesson
Programming language translators
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:

Introduction to Java Tonga Institute of Higher Education

Programming Basics Program – A set of instructions that a computer uses to do something. Programming / Develop – The act of creating or changing a program Programmer / Developer – A person who makes a program Run / Execute – The act of using a program Every program was created by someone Computers use special languages Programmers use special languages to create or change a program

Machine Language Machine language – A language understood by computers When programs are run, machine language is used Machine languages are almost impossible for humans to understand Every operating system (OS) has its own machine language  Windows  Linux  Macintosh Hardware Machine Language High Level Language C++JavaVB.NET

High Level Languages High Level Language - A programming language that is understandable by people This enables a programmer to write programs High level languages must be translated into machine language before running on a computer Hardware Machine Language High Level Language C++JavaVB.NET

Compilers and Interpreters There are two main ways to change programs written in a high level language to machine language: 1. Use a compiler 2. Use an interpreter Source Code – Code written in a programming language by a developer.

Compilers Compiler – A program that transforms code from one format to another Source code Linux compiler Windows compiler Macintosh compiler Linux code Macintosh code Windows code Machine LanguageHigh Level Language Windows Linux Macintosh

Compilers vs. Interpreters Advantages  Programs run faster Disadvantages  Platform dependent - Programs only work on a specific operating system. Windows Linux Macintosh  Compiling a large program may take a long time

Interpreters Interpreter – A program that translates and executes code Usually, interpreters translate and execute source code. Source Code Interpreter High Level Language Code for Windows, Linux and Macintosh Machine Language Windows, Linux and Macintosh

Interpreters vs. Compilers Advantages  Platform Independent.  Don’t need to compile anything. Disadvantages  The interpreter program must be installed on the computer that the program will run on  Slower execution  You should only use services available on all platforms. Example: Windows has a cool sound library, but you can’t use it because it won’t run on Macintosh

Review Give a short description of:  Machine Language  High Level Language Give a short explanation of how an compiler is different from an interpreter

Introduction to Java Java is a programming language created by Sun Microsystems.  Java.sun.com Many programmers use Java Java is an object oriented language.

Java Setup Steps to install Java  Required 1. Install the Java Software Development Kit (SDK)  Find it at  Java 2 Standard Edition  Not Required but good 1. Install Java Documentation 2. Install Integrated Development Environment (IDE)  IDE – A program that helps you to write code

Demonstration Sun Website Java Documentation Java IDE

How Does Java Work? Java uses a compiler and interpreter! You can compile the program once and run it on each platform with an interpreter Source code Java Compiler Byte Code Windows Macintosh Linux Java Interpreter Windows Linux Macintosh

How to Create a Java Program 1. Create a source file. 2. Use the Java compiler to create byte code. 3. Run the byte code using the Java interpreter.

Create a Source File Write Java source code and save it in a file Use a text editor or Integrated Development Environment (IDE). Filename extension:.java

Demonstration Create a source file

Use the Java Compiler to Create Byte Code Source code is compiled by a Java compiler to byte code. Byte Code  A file that can run on any computer that has a Java Interpreter  Filename extension:.class Compiler program: javac.exe Java Compiler Javac.exe Source Code void main () …??this$0?!... Byte Code.java.class

Use the Java Compiler to Create Byte Code Important Details  Javac.exe.java Ex: Javac HelloWorld.java  A.class file is made for every class in the file. Common Errors  Unable to find the Compiler - Something is wrong with your Java setup. Windows can’t find the Java compiler. Is your access to Javac.exe and Java.exe setup properly?  Invalid Flag – One of the inputs are wrong. Did you include the.java extension? Are you using the right file?

Demonstration Compiling Source Code

Run the Byte Code Using the Java Interpreter Java Virtual Machine (JVM) – A program which interprets Java programs that have been compiled into byte-code and usually stored in a ".class" file. Interpreter performs actions  Creates windows  Prints  Etc. Interpreter program: java.exe Java Interpreter Java.exe Byte Code ??this$0?!....class

Run the Byte Code Using the Java Interpreter Important Details  Java.exe Ex: Java HelloWorld  The class name must have the correct case! Common Errors  NoClassDefFoundError – The class can’t be found. Is your class in the correct directory? Are you using the correct case?

Demonstration Running Byte Code