How Java Programs Work MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh.

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

Senem Kumova Metin Introduction to Programming CS 115 Introduction to Computing PART I : Computer Basics PART II: Introduction to Computing/Programming.
Dr. Ken Hoganson, © August 2014 Programming in R COURSE NOTES 2 Hoganson Language Translation.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Copyright © 2002 W. A. Tucker1 Chapter 1 Lecture Notes Bill Tucker Austin Community College COSC 1315.
The Operating System. What is an Operating System? The software which makes it possible for you to use your computer The software which starts up when.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Lecture 1: Intro to Computers Yoni Fridman 6/28/01 6/28/01.
Introduction to Computer Systems
Operating Systems Concepts Professor Rick Han Department of Computer Science University of Colorado at Boulder.
Introduction to Computer Programming CSC 1401: Introduction to Programming with Java Lecture 2 Wanda M. Kunkle.
Chapter 2: Impact of Machine Architectures What is the Relationship Between Programs, Programming Languages, and Computers.
CMP 131 Introduction to Computer Programming Violetta Cavalli-Sforza Week 1, Lab.
Processor Types And Instruction Sets Barak Perelman CS147 Prof. Lee.
The CPU The Central Presentation Unit Language Levels Fetch execute cycle Processor speed.
Systems Software Operating Systems.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
COMP Computer Basics Yi Hong May 13, 2015.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 1 – Introduction to Computers, the Internet, and the Web Outline 1.1 Introduction 1.2 What Is a.
Introduction to Computers and Python. What is a Computer? Computer- a device capable of performing computations and making logical decisions at speeds.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Introduction to Java Tonga Institute of Higher Education.
System Calls 1.
CS413: Java Programming language Applications Applets
COMPUTER SOFTWARE Section 2 “System Software: Computer System Management ” CHAPTER 4 Lecture-6/ T. Nouf Almujally 1.
Computer Hardware and Software Chapter 1. Overview Brief History of Computers Hardware of a Computer Binary and Hexadecimal Numbers Compiling vs. Interpreting.
1 TOPIC 1 INTRODUCTION TO COMPUTER SCIENCE AND PROGRAMMING Topic 1 Introduction to Computer Science and Programming Notes adapted from Introduction to.
111 © 2002, Cisco Systems, Inc. All rights reserved.
Software GCSE COMPUTING.
Computer Platforms Week 4: Assembly Language & Operating Systems.
1 Computing Software. Programming Style Programs that are not documented internally, while they may do what is requested, can be difficult to understand.
CISC105 General Computer Science Class 1 – 6/5/2006.
An Introduction to Computers August 12, 2008 Mrs. C. Furman.
 Why?  Because it can be programmed to do more than one specific task. ◦ Accountants ~ tax forms etc. ◦ Machinists ~ control drilling, lathes etc. ◦
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Introduction to Computer Systems and the Java Programming Language.
Visual C++ Programming: Concepts and Projects
Invitation to Computer Science 5 th Edition Chapter 6 An Introduction to System Software and Virtual Machine s.
Systems Software Operating Systems. What is software? Software is the term that we use for all the programs and data that we use with a computer system.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
CSC 235 Computer Organization. Computer Organizaton ä Top_Level Structure ä The von-Neumann Machine ä Stack Machine ä Accumulator Machine ä Load/Store.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
Chapter 4 Software. Chapter 4: Software Generations of Languages Each computer is wired to perform certain operations in response to an instruction. An.
Chapter 1 Computers, Compilers, & Unix. Overview u Computer hardware u Unix u Computer Languages u Compilers.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
Chapter 1 An Overview of Computers and Programming Languages.
Computer Operation. Binary Codes CPU operates in binary codes Representation of values in binary codes Instructions to CPU in binary codes Addresses in.
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.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Programming Languages Salihu Ibrahim Dasuki (PhD) CSC102 INTRODUCTION TO COMPUTER SCIENCE.
Java Programming: From the Ground Up
Chapter 1 – Introduction to Computers, the Internet, and the Web
Lecture 1: Introduction to JAVA
Introduction to Programming
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Java programming lecture one
Introduction to Java Dept. Business Computing University of Winnipeg
Computer Science I CSC 135.
Computers: Hardware and Software
Introduction CSC 111.
CMP 131 Introduction to Computer Programming
Introduction to Computer Systems
Computer Programming-1 CSC 111
Programming language translators
Presentation transcript:

How Java Programs Work MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation ©Akhilesh Bajaj, All rights reserved

Objectives Understand how Programs are Executed on a Computer Understand how a Java TM program works Let’s get started!

How Programs Work on a Computer Levels of Computer Programming Languages: -First Generation Language: Machine Code Second Generation Language: Assembler Load X into register a -Third Generation Language: Pascal, Fortran, COBOL, C, C++, Java X = 7; -Fourth Generation Language: Visual Basic, Oracle Developer Use a mouse & widgets to create a GUI that executes interface events

How Programs Work on a Computer The CPU (Central Processing Unit) executes the instruction set (machine code) Every program needs to be compiled and ultimately fed to the CPU in the CPU’s language (the instruction set) Different CPUs have different instruction sets (e.g., X86 versus Motorola) The quality of the instruction set can play a bigger role in the performance than other numbers like clock speed. A compiler is a computer program that translates the source code into either machine code or an intermediate language.

How Programs Work on a Computer Once the source code has been compiled into an executable (like a.exe or.bat file on the PC) it can be executed by the CPU. First, the executable is loaded into main memory (RAM). One of the registers in the CPU is the PC (program counter). This has the main memory address of the next instruction to be executed. The CPU fetches the first instruction, executes it, and the PC is updated with the address of the next instruction (which is usually the next line, but may be a jump to another procedure).

How Programs Work on a Computer In addition to instructions, the program also has data (variables, etc) How are these data stored usually? The data locations (referenced by variable names in the source program) are also in main memory (RAM). The CPU needs to be able to fetch these data locations, load them into registers and then perform calculations with them. At the hardware level, the CPU is nothing but a a large logical circuit, that, if fed a certain logical input, generates a predetermined output. The set of all possible inputs is the instruction set of the CPU. The CPU does not “understand” the instructions we feed it in any sense. It simply responds mechanistically to inputs and produces the same output each time for a given input.

How Programs Work on a Computer Figure From our Text Book: Shows the Fetch-and-Execute Cycle

How Programs Work on a Computer For every programming language, the compiler is a program that has a “dictionary” that translates every possible source code statement into a corresponding set of instructions at the lower level (machine code or some intermediate language). Every program executes as a process. The task manager in Windows shows us the processes that are running on our machine. The CPU can also be interrupted by devices like the keyboard and secondary storage (hard disk). This allows multi-programming: E.g., One process is executing, but it needs to read a file from the hard disk. The CPU sends a request to the hard disk manager, and then puts this process in its process queue, takes the next process and executes it. Once the first process’s data is available, the CPU gets the interrupt, takes that first process back in, and continues to execute it.

How Java Programs Work One of the strong points of Java is that it is compile once-run anywhere. How can we do this, if different CPUs (say the X86 CPU in PCs versus the Motorola CPU in Macintosh versus a SUN SPARC CPU) have different instruction sets? Indirection: Create an intermediate layer of instructions using a 2-stage compiler. The first stage takes the.java file and converts it into a.class file of the same name. This is done using the javac program that comes as part of the java SDK. We used this in our first lab to create HelloWorld.class. The code in the.class file is called Java bytecode.

How Java Programs Work This Java bytecode is then run on the JVM (Java Virtual Machine). The JVM is an interpreter, that goes through each line in the bytecode and translates it into the set of instructions for that particular CPU. Clearly different CPUs need different JVMs. Once the JVM is built for that CPU, it will execute any.class file. So, the same.class files will work on any machine that has a JVM. Advantages: -Programmers do not have to distribute source code, only.class files -Programmers do not have to rewrite code if we switch from say PC to apple machines (reuse same.class files) -The JVM can act as a security buffer when code is downloaded from the network (prevents.class files from doing bad things)

How Java Programs Work The JVM is called by the command java that we used in our first lab. So >java HelloWorld executed the.class file and printed out “ Hello World ”. In order to use Java, we need to make sure our CLASSPATH environment variable includes the /lib subdirectory that is part of the SDK. This subdirectory contains all the extensive library classes that we can use. One of the major benefits of Java is that it has an extensive set of these classes whose code can be reused. The CLASSPATH should also have the. in it, so we can also use classes we created that are in the current working directory Finally, the PATH environment variable should have the /bin subdirectory in the SDK, since the java and javac programs are found there.

We learnt how programs are executed We learnt how the java environment works Supporting material is in sections in our online textbook. CONCLUSION