Java Intro III.1 (Fr Feb 23).

Slides:



Advertisements
Similar presentations
Object Oriented Programming in Java George Mason University Fall 2011
Advertisements

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.
How to Create a Java program CS115 Fall George Koutsogiannakis.
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,
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.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
Introduction to Java Tonga Institute of Higher Education.
CSCI 273: Processing An Introduction. Programming Languages –An abstract "human understandable" language for telling the computer what to do –The abstract.
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.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
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.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Clement Allen, PhD Florida A&M University SUMMER 2006.
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
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.
A Look at Java. Categorize Java Which paradigm? Which paradigm? Scripting? Scripting? Declarative or procedural? Declarative or procedural? Which generation?
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java Basics 1 Brief History of Java and Overview of Langauge.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
CSI 3125, Preliminaries, page 1 Compiling the Program.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
Java FilesOops - Mistake Java lingoSyntax
introductory lecture on java programming
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.
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.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
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.
Computer Programming Your First Java Program: HelloWorld.java.
CompSci 230 S Programming Techniques
Lecture 1b- Introduction
John Woodward A Simple Program – Hello world
GC101 Introduction to computer and program
Key Ideas from day 1 slides
Chapter 3 GC 101 Java Fundamentals.
Introduction to.
Programming without BlueJ Week 12
CompSci 230 Software Construction
Chapter 1 Introduction to Computers, Programs, and Java
String Output ICS 111: Introduction to Computer Science I
Introduction to Algorithm Design
Introduction CSC 111.
Java Intro.
Units with – James tedder
Units with – James tedder
(Computer fundamental Lab)
IB Computer Science II Paul Bui
Review of Previous Lesson
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Computer Programming-1 CSC 111
Review of Previous Lesson
Presentation transcript:

Java Intro III.1 (Fr Feb 23)

Java Programming Intro The Rubato Architecture Some History The Java Platform How to Run a Java Class The Oracle Tutorial Our First Program Its First Extension A Second Program

1. The Rubato Architecture

2. Some History Java version 1 (beta) was introduced in 1995 by the SUN computer scientist James Gesling, later Sun was absorbed by the Oracle SW company. Now, we are at Java version 9. We have 9 Mio Java developers in 2017.

3. The Java Platform Java is characterized as a platform-independent language, more precisely, you write a Java program (source code XXX, always with the extender .java, i.e. the source name is XXX.java), then you compile it by the command javac XXX.java and you get the file XXX.class, the so-called bytecode.

3. The Java Platform (cont.) This cannot run, but now, every operating system can have its own interpreter, the so-called Java Virtual Machine JVM, that runs/executes the bytecode by the command java XXX (+ parameters if needed) We shall see in a minute how this is done concretely.

3. The Java Platform (cont.) Java is also an object-oriented language, i.e., its conceptual structure is very much like our form-denotator architecture: it consists of classes which are space types like forms, and objects which are points in the classes, much as denotators are points in forms. class ~ form object ~ denotator We shall see the details soon.

3. The Java Platform (cont.) Most successful modern languages are object-oriented, e.g. C++ (the o.o. extension of C), Objective C (for Mac only), Smalltalk, Eiffel, Delphi, Object Pascal, etc.. But Java is the only successful platform-independent language. This is why I switched to the first version of Rubato, which was first written in Objective C for the NeXT and OS X macs, to Java in 2001 at the CS Department of the U of Zurich.

3. The Java Platform (cont.) Java is implemented in most important OS with about 2000 predefined classes and defines the Java Platform on these OS. There are several fine software environments for Java programming, such as Eclipse for Mac. We shall however not use any of these tools which would take away too much time to be introduced. Instead we shall program everything on the easy environment of text files and the Terminal app.

4. How to run a java class: a) Define the class XXX.java in a text app (not Word, just plain text without hidden formatting) in your DDD folder. b) Open the Terminal app. Change to the DDD folder by the command cd + drag the DDD folder here and return. c) Write ls to see that the file XXX.java is there. d) Write javac XXX.java and return. e) If no error is in the class file, you should now see the class file XXX.class (check with ls). f) Run the program of you class by java XXX (+ parameters if needed).

5. The Oracle Tutorial https://docs.oracle.com/javase/tutorial

6. Our First Program 6.1 Open a text app (like TextEdit on Mac) and set to write plain text. 6.2 Write the following short program (really write everything, it’s important to be able to write the program code!): class HelloWorldApp {   public static void main(String[] args) {     System.out.println("Hello World!"); // Display the string.     } }

6. Our First Program 6.3 Save this file in DDD exactly under the name HelloWorldApp.java 6.4 Compile it by javac HelloWorldApp.java 6.5 Check by ls that we now have the class file HelloWorldApp.class 6.6 Run it by java HelloWorldApp

Short Discussion of Code Structure opening bracket of class class signature main method's name class name arguments of method opening bracket of method class HelloWorldApp {   public static void main(String[] args) {     System.out.println("Hello World!"); // Display the string.     } } print method's name print method's argument a comment closing bracket of method closing bracket of class   public static void method accessible to all programmers class method method does not return anything to the program

Hello Jay Afrisando! or Hello Zilu Chen! i.e., your own name. 7. Its First Extension Want to write a program that prints also your name, not just a generic greeting sentence. Like Hello Jay Afrisando! or Hello Zilu Chen! i.e., your own name. 7.1 To this end, we use the input argument String[] args of the main method. This is an array of String objects, like (“Jay”, “Afrisando”) which is an array of two Strings: args[0] is “Jay”, and args[1] is “Afrisando”.

7. Its First Extension (cont.) We now want these arguments to be part of our text. We therefore write concatenation of String objects System.out.println("Hello "+ args[0]+" "+args[1]+ "!"); first String object first String object of argument which is a String array (= sequence of String objects starting from index 0, then index 1, etc.) empty space String object second String object of argument ! String object

7. Its First Extension (cont.) and get the code (without the comment): class HelloMyWorld { public static void main(String[] args){ System.out.println("Hello "+ args[0]+" "+args[1]+"!"); } 7.2. Now compile HelloMyWorld.java! You get HelloMyWorld.class run it! But also write the two arguments, you name: java HelloMyWorld Zilu Chen

8. A Second Program