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.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Chapter 1 These slides for CSE 110 Sections are based in part on the textbook-authors’ slides, which are copyright by the authors. The authors state that.
How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
How to Create a Java program CS115 Fall George Koutsogiannakis.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
Java Programming Working with TextPad. Using TextPad to Work with Java This text editor is designed for working with Java You can download a trial version.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
01 Introduction1June Introduction CE : Fundamental Programming Techniques.
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.
How do we make our Welcome.java program do something? The java in our Welcome.java file won’t do anything by itself. We need to tell the computer to execute.
A tour around Java General introduction to aspects of the language (these will be covered in more detail later) After this tour you should have a general.
Introduction to Java.
Using the Java programming language compiler. Review of relevant material from previous lectures From previous lectures: A computer can only execute machine.
Programming a computer. What does programming a computer mean ? Programming a computer: Since a computer can only execute machine instructions (encoded.
public static void main (String[] args)
PYTHON: LESSON 1 Catherine and Annie. WHAT IS PYTHON ANYWAY?  Python is a programming language.  But what’s a programming language?  It’s a language.
IB Computer Science II Paul Bui
“Introduction to Programming With Java”
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.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
CSCI 273: Processing An Introduction. Programming Languages –An abstract "human understandable" language for telling the computer what to do –The abstract.
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level 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.
What is a Computer? An, electrical machine, that can be programmed to accept data (input), process it into useful information (output) and store it away.
Tutorial 1. Q1: Compare and contrast between multiprocessors and multicore Multicore – Dual-core processor has two cores (e.g. AMD Phenom II X2, Intel.
Big Java by Cay Horstmann Copyright © 2008 by John Wiley & Sons. All rights reserved. Chapter One: Introduction.
Week 1 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Welcome to the Lecture Series on “Introduction to Programming With Java”
©2000, John Wiley & Sons, Inc. Horstmann/Java Essentials, 2/e Chapter 1: Introduction 1 Chapter 1 Introduction.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
FRST JAVA PROGRAM. Getting Started with Java Programming A Simple Java Application Compiling Programs Executing Applications.
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.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Programming Concept Chapter I Introduction to Java Programming.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
CSCI Processing CSCI Introduction to Algorithm Design An Introduction.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To understand the activity of programming To learn about the architecture.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
Pre-Sessional Java Programming Lecture 1a Reyer Zwiggelaar
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Introduction to Python Lesson 1 First Program. Learning Outcomes In this lesson the student will: 1.Learn some important facts about PC’s 2.Learn how.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
CSI 3125, Preliminaries, page 1 Compiling the Program.
Chapter 1 Introduction. Chapter Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Java FilesOops - Mistake Java lingoSyntax
CHAPTER 1 INTRODUCTION. CHAPTER GOALS To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Computer Science Reaching Wider Summer School 2012.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Chapter 1 - Introduction. Announcements Info Sheet Web Site: Lab Hours NotecardsPictures.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
CS 177 Recitation Week 1 – Intro to Java. Questions?
1/16: Intro to Java, Languages, and Environments Types of programming languages –machine languages –assembly languages –high-level languages Java environment.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to Computers,
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Introduction to programming in java
John Woodward A Simple Program – Hello world
Programming without BlueJ Week 12
Introduction to Algorithm Design
Java Intro.
Run Java file with Window cmd
IB Computer Science II Paul Bui
Presentation transcript:

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 to execute the program in the file. This is a two-stage process. First stage: Compile the program into a concise set of instructions your computer can carry out directly >javac HelloTester.java Second stage: Tell the computer to carry out the compiled instructions >java HelloTester Welcome to Java javac stands for java compiler Tells the computer to execute the compiled java instructions in HelloTester.class javac puts the compiled instructions in a new file HelloTester.class

Translating from high to low..... Human speaks English Programmer encodes problem in a high-level Language (Java) Compiler Translates Java into compiled code Computer executes machine code instructions

public class HelloTester { public static void main(String[] args){ System.out.println(“Hello World”); } Java source code in a file called HelloTester.java 3%(*$&£.... (*&£*&£ *(&^^!__£+ (£()*&(*H###~}{}{} (*(*(*(*£ Java machine code in file HelloTester.class Program instructions carried out JAVAC compiles the source code JAVA virtual machine executes code

Writing your first program Open a new file in Notepad (or any other simple editor; not Word, tho!). You’ll find Notepad under Programs\Accessories. Type the HelloTester.java code into this new file. Save the file in the Java folder in your home directory, with the name HelloTester.java You have now written and saved your first draft of the program. Next you need to compile your program (convert it into a form that can do something), and once compiled, to run it (see what it does). Exit Notepad.

Compiling your program Open the command prompt on your computer. You’ll find this under Programs\Accessories. The command prompt is a window that allows you to type commands directly to the computer. Type cd Java  (this command puts you in the Java folder in your C: disk) Type dir  to get a dir ectory of all files in C:\Java (you will see HelloTester.java) Type C:  at the command prompt (this puts you in your C: disk) Type mkdir Java  (this command creates a Java folder for you in your C: disk)

Compiling your program (continued) Type dir  to get a dir ectory of all files in C:\Java (you will now see HelloTester.java and HelloTester.class, if there were no compilation errors) Type javac HelloTester.java  The javac command compiles your high-level HelloTester.java file into a bytecode program in a file HelloTester.class If there are any “grammatical” errors in your HelloTester.java program (and there often are!) javac will print them out.

Running your compiled program Type java HelloTester  to run the HelloTester program The java command gets the file HelloTester.class and executes the machine code (bytecode) commands in that file. If your HelloTester.java program compiled correctly (with no errors), you will now have a HelloTester.class that can be run. Commands java HelloTester.class or java HelloTester.java won’t work because the java command will look for HelloTester.class.class or HelloTester.java.class If your program is written correctly, when run it’ll display Welcome to Java! on the command prompt

Homework Read Horstmann, Chapter 1 Try programming exercise P1.1. You can use the HelloTester.java program as a template for this programming exercise. You will also be doing programming exercises in your practicals. Next we will take a tour around Java using the BouncingBall program. At the end of that tour you will have an understanding of some important ideas in java.

Computer labs start next week (15 th ) Where are the labs? Go up the stairs in the computer science building to the first floor. Turn right and go down to the end of the corridor; the first year labs are facing you. The labs are called the “active learning labs”. Bring your laptop!!! Labs are Tuesday 2-4 or Thursday 2-4; pick one time.