Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.

Slides:



Advertisements
Similar presentations
1 G54PRG Programming Lecture 1 Amadeo Ascó Adam Moore G54PRG Programming Lecture 1 Amadeo Ascó 3 Java Programming Language.
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
The Web Warrior Guide to Web Design Technologies
Lab#1 (14/3/1431h) Introduction To java programming cs425
Introduction to Java Kiyeol Ryu Java Programming Language.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
2012 •••••••••••••••••••••••••••••••••• Summer WorkShop Mostafa Badr
JAVA: An Introduction to Problem Solving & Programming, 6 th Ed. By Walter Savitch ISBN © 2012 Pearson Education, Inc., Upper Saddle River,
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/10) An Overview of Objects and the Java API Joel Adams and Jeremy Frens.
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.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
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.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
POS 406 Java Technology And Beginning Java Code
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Lecture 8 February 29, Topics Questions about Exercise 4, due Thursday? Object Based Programming (Chapter 8) –Basic Principles –Methods –Fields.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Java Basics 1 Brief History of Java and Overview of Langauge.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
introductory lecture on java programming
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Aside: Running Supplied *.java Programs Just double clicking on a *.java file may not be too useful! 1.In Eclipse, create a project for this program or.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
M1G Introduction to Programming 2 2. Creating Classes: Game and Player.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Winter 2006CISC121 - Prof. McLeod1 Last Time Reviewed class structure: –attributes –methods –(inner classes) Looked at the effects of the modifiers: –public.
World Wide Web has been created to share the text document across the world. In static web pages the requesting user has no ability to interact with the.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Introduction to JAVA Programming
Today Encapsulation. Build a fully encapsulated Halloween class, going from Halloween1 to Halloween6 (eventually!): –The final version will have overloaded.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Intro to ETEC Java.
Chapter 1 Introduction to Computers, Programs, and Java
Chapter No. : 1 Introduction to Java.
Java Primer 1: Types, Classes and Operators
Your First Java Application
CMPE212 – Stuff… Course Web Site:
Introduction CSC 111.
Units with – James tedder
CISC124 From Thursday: Course Web Site:
(Computer fundamental Lab)
CMPE212 – Reminders Course Web Site:
CMPE212 – Reminders Course Web Site:
Review of Previous Lesson
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming language for (From Tiobe.com). Winter 2016CMPE212 - Prof. McLeod1

Winter 2016CMPE212 - Prof. McLeod2

Over Time: Winter 2016CMPE212 - Prof. McLeod3

Winter 2016CMPE212 - Prof. McLeod4 A Very Brief History of Java The language was first developed by James Gosling at Sun Microsystems in –He was designing a language, called “Oak”, for the “Green Project”. –The Green Project envisaged the centralized control of many processor-based devices in the home. − “Oak” was designed to be a robust, efficient language with maximum portability to different processors. − The Green Project flopped…

Winter 2016CMPE212 - Prof. McLeod5 Java History, Cont. Internet use started to blossom in the early 90’s. Web pages had to do more than just display static text and graphics. Needed dynamic and interactive content. But, web pages are viewed on a wide variety of platforms, from Mac’s to Unix to IBM-PC’s. So any page-embedded language would need to run on all these platforms. Needed a robust, compact, multiplatform language, so let’s dust off Oak and call it something racy like “Java”! What else happened in the early 90’s?

Winter 2016CMPE212 - Prof. McLeod6 Java History, Cont. In 1994, Sun demonstrated the use of Java in small bundles of code embedded in a web page - called applets. Netscape browsers started supporting applets in 1995, starting Java’s rise to fame. Sun programmers continued to develop a code base for the language, adding many libraries. They showed that Java could be used for more than just applets, and that full-blown applications could be written in this high-level language.

Winter 2016CMPE212 - Prof. McLeod7 How Java Works The Java language standard (the syntax) is identical for all platforms. A compiler ( part of the “JDK”, or “Java Development Kit” – sometimes called javac.exe) which is designed to run on your development platform, compiles your source code (*.java file) to a byte code file (*.class file). The byte code file is platform-independent, and is the thing you attach to your web page as an applet. Every browser written for every platform and OS, can have an embedded code processor called a JVM, or “Java Virtual Machine”, built-in.

Winter 2016CMPE212 - Prof. McLeod8 How Java Works, Cont. The JVM takes the byte code and executes it by generating the machine code that will be recognized by the platform that is running the browser. HTML File Applet Remote File Server Browser Local Client JVM Internet Byte code files

Winter 2016CMPE212 - Prof. McLeod9 How Java Works, Cont. Of course it did not take long before people took the JVM out of the browser so that they could run stand-alone Java applications. This is the JRE or “Java Runtime Engine” (java.exe). The concept of write once, run anywhere is very appealing! “Save your $$!” And, Oracle distributes the JDK’s for free, making development on many platforms inexpensive.

Winter 2016CMPE212 - Prof. McLeod10 How Java Works, Cont. However, all IDE’s, including Eclipse, must use the appropriate JDK in the background. Two components of the JDK are the programs “javac.exe” and “java.exe”. javac.exe is the byte code compiler, and java.exe is the JRE which executes the byte code file. “Compilation” is the process of converting the *.java file to a *.class file (the byte code file). This is done by calling javac.exe in the background, and supplying that program with all the required command line parameters.

Winter 2016CMPE212 - Prof. McLeod11 How Java Works, Cont. The java.exe program: –accepts the byte code file, –links in any required libraries, –creates executable code in memory –converts it to machine language –and sends it to the CPU. The java.exe program must know the right machine language commands for just the type of CPU it is designed for!

Winter 2016CMPE212 - Prof. McLeod12 OOP in Java A class definition or “object definition”, consists of the definition of instance variables and/or methods. By convention, instance variables are all declared before the methods: public class ShowStructure { // instance variables or “attributes” here // methods here } // end class ShowStructure

Winter 2016CMPE212 - Prof. McLeod13 OOP in Java – Cont. In Java, a class is an Object, and an Object is a class (rather Zen is it not!) A variable can be used to address an instance of a class, which is also an Object. Code and attributes cannot be defined outside of a class. The only code that can exist outside a method are attributes or other (“inner”) class definitions.

Winter 2016CMPE212 - Prof. McLeod14 Attributes Also called “class variables” or “instance variables” or “fields”. Declared within a class at the same level as the method declarations. These variables are known to all methods within a class (their “scope”). You can control their privacy and the way they are stored in memory (using public / private / protected and static ).

Winter 2016CMPE212 - Prof. McLeod15 Attribute Declaration Syntax: [private|public] [static] [final] type attributeName [= literalValue]; Note that the type part is not optional – this is why java is a “declarative” language. And, a variable cannot change its type later (“static typing”). You cannot use a variable unless you have declared it first.

Winter 2016CMPE212 - Prof. McLeod16 Variable Declaration Declaring a variable inside a method gives that variable the scope of just inside the method, not outside the method. Generally a variable is only available inside the block ( {…} ) in which it is declared. The syntax for declaration inside a method is the same except you don’t need the [private|public] [static] [final] parts.

Winter 2016CMPE212 - Prof. McLeod17 The syntax for simple method declaration: [private|public] [static] [final] returnType methodName ([parameterList]) {…} If main invokes methods or uses attributes in the same class as itself then those attributes and methods must also be declared static. Method Declaration (a “Header”)

Winter 2016CMPE212 - Prof. McLeod18 Method Declaration - Cont. A method must have a returnType. The returnType can be any single Object or a primitive type. (For example: an int, double, String, an array (like int[], or any other pre- defined Object.) If the method does not return anything, then the keyword void is used instead. The main method does not return any value, so that’s why it is declared as in: public static void main (String[] args) {…}

Winter 2016CMPE212 - Prof. McLeod19 Aside - The main Method For the JVM to run an application, it must know where to start. By design, the starting point is always the execution of the main method. The JVM expects the main method to be declared exactly as shown – the only thing you can change is the name of the String array, called args above.

Winter 2016CMPE212 - Prof. McLeod20 Method Declaration - Cont. parameterList provides a means of passing items, or parameters, into a method. It is optional. It can consist of one or many parameters, separated by commas. Each parameter type must be declared in the parameter list, as in type variableName, type variableName, …