Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News
13 X 11 Java Lecture 1 CS 1311 Introduction 13 X 11.
Object Oriented Programming in Java George Mason University Fall 2011
Welcome to Java Programming. Why do I want to take this course? I want to major in EE/CSE. ECE122 is a requirement. Java is hot in Job market. It is useful.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. OBJECTIVES FOR THIS UNIT Upon completion of this unit, you should be able to: Explain the Java virtual machine.
MC697 Object-Oriented Programming Using Java. In this class, we will cover: How the class will be structured Difference between object-oriented programming.
Chapter 2: Your First Program! Hello World: Let’s Program  All programs must have the extension.java  Our first program will be named: HelloWorld.java.
Software. What Is Software? software –Also called Computer programs –Are a list of instructions –Instructions are called code –CPU performs the instructions.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
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 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
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.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Getting Started with Java
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
IB Computer Science II Paul Bui
Introduction to Java Tonga Institute of Higher Education.
Introducing Java.
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.
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.
CS 106 Introduction to Computer Science I 01 / 25 / 2010 Instructor: Michael Eckmann.
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.
Chapter 1 CSIS-120: Java Intro. What is Programming?  A: It is what makes computer so useful.  The flexibility of a computer is amazing  Write a term.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
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.
Your First Java Application Chapter 2. 2 Program Concepts Modern object-oriented programs help us build models to manage the complexity found in a problem.
Introduction to C++ Programming Language
POS 406 Java Technology And Beginning Java Code
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Programming Concept Chapter I Introduction to Java Programming.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
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.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
Java Basics 1 Brief History of Java and Overview of Langauge.
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
CS 106 Introduction to Computer Science I 01 / 22 / 2007 Instructor: Michael Eckmann.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
CS 106 Introduction to Computer Science I 01 / 22 / 2008 Instructor: Michael Eckmann.
CS 177 Recitation Week 1 – Intro to Java. Questions?
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.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
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.
CIS 234: Object-Oriented Programming with Java
Lecture 1b- Introduction
CSCI-235 Micro-Computer Applications
Key Ideas from day 1 slides
Introduction to.
CompSci 230 Software Construction
Introduction to Java Dept. Business Computing University of Winnipeg
Your First Java Application
Programming Languages
IB Computer Science II Paul Bui
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Presentation transcript:

Compiling and the Java Virtual Machine (JVM)

The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized the importance of structure Compilers essentially require perfection. The procedure for writing your algorithms won’t change (much!) –Write a high level approach focusing on algorithm. –Write the code concentrating on details. –Check it by hand before compiling. Because we're introducing a real language at the same time as we're introducing the object oriented paradigm we will require you to just write some code. –You may not understand it all immediately –Eventually we'll explain! Working with a real language

The First Part Initially we’ll use Java to write procedural code just to let you get the feel of a real language. In fact, we’ll start by programming some of the same types of modules that we used in the procedural pseudocode earlier in the semester. Then, as we introduce the Object Oriented paradigm we’ll use Java as it was intended.

About Java

Introduction to Java What Java is: –A real professional programming language (which is good and bad...) –Portable across any hardware platform that has a JVM interpreter (more later) –An object-oriented language What Java is not: –“The Ultimate Programming Language” –HTML or another web-content language –Only useful for web applets –Just Another Vacuous Acronym

Real Languages Real languages require the programmer to write code using a very specific set of rules, keywords and syntax. Then this code is transformed into actual instructions that a specific machine can execute. [Often a complex process] A number of strategies have been invented to accomplish this process –Assemblers –Compilers –Interpreters A traditional problem has been the necessity to have different versions of a program for different machines.

A New Idea Java was specifically developed to be able to write code once and run it anywhere How is this magic accomplished? Using an intermediate language! Byte code. The Byte code is interpreted (executed) using a special piece of software (a program) called the Java Virtual Machine (JVM)

“Source Code” [.java] Java compiler Generic “Byte Code” [.class] OS-specific JVM interpreter OS-specific “Object Code” Execute program Compilation Need one of these for every different OS

Structure of Java Programs Initially we’ll write programs that fit in one file. –Create the file with an editor (e.g. emacs) –Compile with javac producing a.class file –Execute by running java and sending it the.class file Our first (tiny) program will be roughly like a cross between an algorithm and a procedure. Let’s take a look...

Sample Application public class HelloWorld { public static void main(String argv[]) { System.out.println(“Hello World!”); } We create a file (using an editor) called “HelloWorld.java” We compile by typing (at the OS prompt): javac HelloWorld.java Which produces HelloWorld.class Then we execute by typing: java HelloWorld Hello World!

Demo >javac HelloWorld.java >java HelloWorld Hello World! >

Quick Trix The name of the file must match the name of the class EXACTLY!!! File: Bubba.java Contains: Everything must be EXACTLY correct!!! class Bubba {... Capitalization counts

Eventually... Applications* (“normal” computer programs): –Each program consists of multiple files. –Each file contains a class. –Each class will contain modules which will resemble procedures and functions. METHODS –THE MODULES WILL BE CALLED METHODS main –The.class file that you send to java must contain a method named main –It will actually look like this: public static void main(String argv[] ) {.. } –the JVM will use the file naming convention to find the other classes required by this main program. *As opposed to Applets

Some basic syntax issues Your TA is smarter than the java compiler Lines need to terminate with a ; –Easier said than done Braces will be used to indicate "blocks" of code –Which essentially act like a single line public class HelloWorld { public static void main(String argv[]) { System.out.println(“Hello World!”); }

A look ahead... Pseudocode if some_boolean then a <- a + 1 else a <- a + 2 b <- 7 endif Note: Indentation is used in both cases. Means nothing to compiler. = instead of <- (more later) Must have parens in Java Java if(some_boolean) a = a + 1; else { a = a + 2; b = 7; } Note ; placement