Lesson 04: Our First Java Program (W01D4

Similar documents
The Command Shell. Fundamentals of Computer Science

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

CSC116: Introduction to Computing - Java

CSC116: Introduction to Computing - Java

Lesson 12: OOP #2, Accessor Methods (W03D4)

CSC116: Introduction to Computing - Java

Fundamentals of Programming. By Budditha Hettige

Instructions. First, download the file

Lesson 36: for() Loops (W11D1)

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Getting Started with Java. Atul Prakash

CSCI 161: Introduction to Programming I Lab 1b: Hello, World (Eclipse, Java)

Code Ninjas: Introduction to Computer Science. Macomb Science Olympiad Presented by Swati Dharia

Certified Core Java Developer VS-1036

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

CS 177 Recitation. Week 1 Intro to Java

C02: Overview of Software Development and Java

Life Without NetBeans

Java Bytecode (binary file)

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

Lec 3. Compilers, Debugging, Hello World, and Variables

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

1. Download the JDK 6, from

Chapter Two Bonus Lesson: JavaDoc

These two items are all you'll need to write your first application reading instructions in English.

AP Computer Science Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Lesson 10: Quiz #1 and Getting User Input (W03D2)

Class 1: Homework. Intro to Computer Science CSCI-UA.0101 New York University Courant Institute of Mathematical Sciences Fall 2017

IT151: Introduction to Programming (java)

Department of Computer Science University of Pretoria. Introduction to Computer Science COS 151

Inf1-OP. Course Overview. Volker Seeker, adapting earlier version by Perdita Stevens and Ewan Klein. February 26, School of Informatics

Programming with Java


Inf1-OOP. Textbooks. Who and What. Organizational Issues. Why Java? Course Overview. Hello, World! in Java. Ewan Klein, Perdita Stevens

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

CHAPTER 1. Introduction to JAVA Programming

Administrative Stuff. Inf1-OP. Additional help? Who to contact for help? Course Overview

Inf1-OOP. Textbooks. Who and What. Organisational issues. Why Java? Course Overview. Hello, World! in Java

CS 11 java track: lecture 1

Lesson 24: Recursive Algorithms #1 (W07D3)

List of Slides 1 Title 2 Chapter 2: Sequential execution and program errors 3 Chapter aims 4 Section 2: Example:Hello world 5 Aim 6 Class: programs ar

Who and what can help? Inf1-OP. Lecturer: Timothy Hospedales TA: Natalia Zon

You will need to download the Java software development kit from

Lesson 01 Introduction

CPSC 150 Laboratory Manual. Lab 1 Introduction to Program Creation

Computer Hardware. Java Software Solutions Lewis & Loftus. Key Hardware Components 12/17/2013

Introduction Basic elements of Java

BASICS.

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

17 Hello world 18 Type: String: literal 19 Standard API: System: out.println() 20 Hello world 21 Statement 22 Statement: simple statements are ended w

Summer Assignment for AP Computer Science. Room 302

CompSci 125 Lecture 02

Exercise 1: Intro to Java & Eclipse

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG

Java: Comment Text. Introduction. Concepts

lejos NXJ Problem Solving with Robots [PRSOCO601]

Lecture 1 - Introduction (Class Notes)

Lab # 2. For today s lab:

CSCI 2132: Software Development. Norbert Zeh. Faculty of Computer Science Dalhousie University. Shell Scripting. Winter 2019

You should see something like this, called the prompt :

Refresher workshop in programming for polytechnic graduates General Java Program Compilation Guide

Creating a Program in JCreator. JCreator is then used to create our program. But the first step is to create a new file.

CMSC 150 LECTURE 1 INTRODUCTION TO COURSE COMPUTER SCIENCE HELLO WORLD

Lecture 4: Introduction to Java and your Development Environment

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Setting up your Computer

Getting Started (1.8.7) 9/2/2009

Project 1. Java Control Structures 1/17/2014. Project 1 and Java Intro. Project 1 (2) To familiarize with

COMP 110 Project 1 Programming Project Warm-Up Exercise

St. Edmund Preparatory High School Brooklyn, NY

Software Installation for CS121

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

Lecture 1: Introduction to Java

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Introduction to Java. Nihar Ranjan Roy.

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

At its simplest, a computer is a collection of wires, transistors and electrical components that are connected in a specific way When you send

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

Get JAVA. I will just tell you what I did (on January 10, 2017). I went to:

13 th Windsor Regional Secondary School Computer Programming Competition

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

NetBeans IDE Java Quick Start Tutorial

Programming Language Concepts: Lecture 1

CS125 : Introduction to Computer Science. Lecture Notes #4 Type Checking, Input/Output, and Programming Style

Chapter 3 Intro to Java

Università degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M

Linux File System and Basic Commands

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 1

Kickstart Intro to Java Part I

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

USING THE OOSIML/JAVA COMPILER. With the Command Window

Eclipse. JVM, main method and using Eclipse. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Lab: Supplying Inputs to Programs

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

USING THE OOSIML/JAVA. With a Terminal Window

Getting started with Java

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

Transcription:

Lesson 04: Our First Java Program (W01D4) Balboa High School Michael Ferraro <mferraro@balstaff.org> Lesson 04: Our First Java Program (W01D4

Do Now Start a terminal shell. From there, issue these commands and then come up with an explanation for what s happening. You may be asked to share with the class. env echo "Hello" echo "Hello, $USER" APCS="cool" echo "$APCS" APCS="I am $APCS" echo "$APCS" Lesson 04: Our First Java Program (W01D4

Aim Students will learn about environment variables, go over the home Java development setup, and work on their first Java program,helloworld. Lesson 04: Our First Java Program (W01D4

Recap of Environment Variables In general, variables are containers for information that needs to be remembered, later recalled, possibly changed, recalled again, etc. Environment vars maintain information about the running state of the operating system. (See the output of theenv command.) What happens when you type the name of a program (or command) that isn t in the current directory? Lesson 04: Our First Java Program (W01D4

A Clever Solution tol02 HW Let s see a clever solution to the last HW a... a Note for teacher:watch,mv Lesson 04: Our First Java Program (W01D4

Our First Program Here s an outline of the process for writing a simple program: Use a text editor (e.g.,gedit or Notepad) to write source code. Lesson 04: Our First Java Program (W01D4

Our First Program Here s an outline of the process for writing a simple program: Use a text editor (e.g.,gedit or Notepad) to write source code. From the command prompt, compile the program into Java bytecode usingjavac. Lesson 04: Our First Java Program (W01D4

Our First Program Here s an outline of the process for writing a simple program: Use a text editor (e.g.,gedit or Notepad) to write source code. From the command prompt, compile the program into Java bytecode usingjavac. Run the Java class file usingjava. Lesson 04: Our First Java Program (W01D4

Our First Program Here s an outline of the process for writing a simple program: Use a text editor (e.g.,gedit or Notepad) to write source code. From the command prompt, compile the program into Java bytecode usingjavac. Run the Java class file usingjava. EDIT COMPILE RUN Lesson 04: Our First Java Program (W01D4

Step 1: Source Code 1. Start a terminal shell. 2. Create a directory to contain our work: /home/student/desktop/firstprogram 3. cd to the FirstProgram directory. 4. gedit HelloWorld.java & Lesson 04: Our First Java Program (W01D4

Step 1: Source Code 1. Start a terminal shell. 2. Create a directory to contain our work: /home/student/desktop/firstprogram 3. cd to the FirstProgram directory. 4. gedit HelloWorld.java & Notes about Java source file names: All Java sources end in.java The first letter of each word in the filename is capitalized CamelCase. Lesson 04: Our First Java Program (W01D4

Step 1: Source Code public class HelloWorld { All Java programs need aclass statement that contains all the rest of the code. The class name must match the filename (minus the.java extension).

Step 1: Source Code public class HelloWorld { Make room for what s next!

Step 1: Source Code public class HelloWorld { PRESS [TAB] TO INDENT...

Step 1: Source Code public class HelloWorld { public static void main(string[] args) { main() is a Java method. When thehelloworld program is run, whatever code appears within this method will be the first to run.

Step 1: Source Code public class HelloWorld { public static void main(string[] args) { Make room...

Step 1: Source Code public class HelloWorld { public static void main(string[] args) { System.out.println(); System.out.println() is a Java statement. Think of it as a command that we might run at the command prompt.

Step 1: Source Code public class HelloWorld { public static void main(string[] args) { System.out.println(); System.out.println() is a Java statement. Think of it as a command that we might run at the command prompt. Just asls can take arguments as inls /etc/*.conf so too cansystem.out.println() in Java. Instead of taking filenames, it takes astring, or text, to be printed to the screen.

Step 1: Source Code public class HelloWorld { public static void main(string[] args) { System.out.println("Hello, World!"); In Java,Strings must be wrapped in double quotes ( ).

Step 1: Source Code public class HelloWorld { public static void main(string[] args) { System.out.println("Hello, World!"); Save the file!

Step 2: Compile the Source Back to the terminal shell: ls -l make sure you seehelloworld.java

Step 2: Compile the Source Back to the terminal shell: ls -l make sure you seehelloworld.java Compile your Java source code into a new, Java bytecode file: javac HelloWorld.java

Step 2: Compile the Source Back to the terminal shell: ls -l make sure you seehelloworld.java Compile your Java source code into a new, Java bytecode file: javac HelloWorld.java See what s changed: ls -l

Step 2: Compile the Source Back to the terminal shell: ls -l make sure you seehelloworld.java Compile your Java source code into a new, Java bytecode file: javac HelloWorld.java See what s changed: ls -l HelloWorld.class is a Java class file that can be run!

Step 3: Run the Class java HelloWorld java runs the Java Virtual Machine (a.k.a. JVM). It knows how to find a Java class in the current directory (or in aclasspath) and run Java bytecode, or a set of instructions that it understands how to interpret.

HelloWorld in Windows Many of you will repeat this process in Windows at home. Let s practice here. Reboot into Windows Using Notepad, we ll composehelloworld.java Use a command prompt to compile and run HelloWorld

HW Your HW is to get your home computer ready to edit, compile and run Java programs. Once that s done, repeat today s activity: HelloWorld. Mac OS/X: You likely already have the JDK installed (i.e.,java and javac already work from your terminal). In Spotlight, typeterminal to find your Terminal application. Then follow the instructions in the earlier slides, usingtextedit as your text editor. a Windows: Follow the instructions in this PDF file for getting the Oracle JDK installed and configured on your computer. Go on to the next slides... a Make sure you savehelloworld.java as plain text!

HelloWorld on Windows 1. Start a Command Prompt (Windows key + R cmd) 2. cd Desktop 3. mkdir FirstProgram 4. cd FirstProgram 5. notepad HelloWorld.java retype the source code on the final Step 1: Source Code slide save the file (ctrl + s) 6. javac HelloWorld.java 7. java HelloWorld