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.

Slides:



Advertisements
Similar presentations
compilers and interpreters
Advertisements

Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
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.
CPSC150 Fall 2008 Dr. L. Lambert. CPSC150 Overview Syllabus Use Textbook, ask questions, extra thorough, I will post sections covered All information.
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.
Lecturer: Fintan Costello Welcome to Hdip 001 Introduction to Programming.
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.
CHAPTER 1 INTRODUCTION GOALS  To understand the activity of programming  To learn about the architecture of computers  To learn about machine code and.
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.
 2003 Prentice Hall, Inc. All rights reserved. Customized by Sana Odeh for the use of this class. 1 Introduction to Computers and Programming in JAVA.
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,
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer 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.
Unit2: Object-oriented programming Getting started with Java Jin Sa.
CS1020: Intro Workshop. Topics CS1020Intro Workshop Login to UNIX operating system 2. …………………………………… 3. …………………………………… 4. …………………………………… 5. ……………………………………
Welcome to COMP 1001 First Year Computer Science Lecturer: Fintan Costello.
Introduction to Java.
Assembler Compiler Interpreter ASSEMBLER To convert the assembly language into machine code. Translate mnemonic operation codes to their machine language.
Using the Java programming language compiler. Review of relevant material from previous lectures From previous lectures: A computer can only execute machine.
public static void main (String[] args)
IB Computer Science II Paul Bui
“Introduction to Programming With Java”
Agenda What is Computer Programming? The Programming Process
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.
CSCI 273: Processing An Introduction. Programming Languages –An abstract "human understandable" language for telling the computer what to do –The abstract.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
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.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Tutorial 1. Q1: Compare and contrast between multiprocessors and multicore Multicore – Dual-core processor has two cores (e.g. AMD Phenom II X2, Intel.
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.
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.
Clement Allen, PhD Florida A&M University SUMMER 2006.
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.
Fall 2006Slides adapted from Java Concepts companion slides1 Introduction Advanced Programming ICOM 4015 Lecture 1 Reading: Java Concepts Chapter 1.
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.
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.
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,
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to Object Oriented
Introduction to programming in java
Object-Oriented Programming Using Java
Chapter 3 GC 101 Java Fundamentals.
Programming without BlueJ Week 12
Hands-on Introduction to JAVA
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 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 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 Welcome.java Second stage: Tell the computer to carry out the compiled instructions >java Welcome Welcome to Java javac stands for java compiler Tells the computer to execute the compiled java instructions in Welcome.class javac puts the compiled instructions in a new file Welcome.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 Welcome { public static void main(String[] args){ System.out.println(“Welcome to java”); } Java source code in file Welcome.java 3%(*$&£.... (*&£*&£ *(&^^!__£+ (£()*&(*H###~}{}{} (*(*(*(*£ Java bytecode in file Welcome.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 Welcome.java code into this new file. Save the file in the Java folder in your home directory, with the name Welcome.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 H:\Java  at the command prompt (this command puts you in the Java folder of your Home ( H: ) directory) Type dir  to get a dir ectory of all files in H:\Java (you will see Welcome.java)

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

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

Homework Read Liang, pp (top of page) Do review questions, p. 26: You will also be doing programming exercises in your practicals.

Computer labs start next week (27 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. Go in and pick a computer. You must go at the time allocated for your group, as listed on the following slides.

Lab Times each Week You must go to the labs at the time for your option. Arts: Monday 4-6 Actuarial & Finance: Thursday 4-6 Denominated Computer Science : Monday 2-4 Denominated Computer Science : Tuesday 2-4 Denominated entry computer science have a choice: IMPORTANT: If you are a Denominated Computer Science student who is doing CHEMISTRY, you MUST sign up for the MONDAY 2-4 labs. This is because your chemistry labs will be on Tuesday.

General Science lab times General Science option G : Tues 4-6 or Wed 4-6 General Science option F, J, or M : Thursday 2-4 General Science option I or O : Wed 2-4 General Science option H or K : Mon 2-4 or Tues 2-4 (Students doing option H must go to the computer lab time that does not clash with their chemistry time) (Students doing option G must go to the computer lab time that does not clash with their chemistry time)

What you need in computer labs To use the computer labs, you need two things. 1) Your student account and password (this will have been given to you on registration). (Your student account will look like a random sequence of letters and numbers, maybe something like 2)Your student number (this will be on your Student Card). If you haven’t registered yet, simply bring along your CAO number. 3)You need both account+password and student number!