Introduction to Java Programming

Slides:



Advertisements
Similar presentations
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Advertisements

Object Oriented Programming in Java George Mason University Fall 2011
Object Orientated Programming
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Created by Ron Beglieter (based on the Java Tutorial) 1 What is Java? Java technology is both a programming language and a platform; Programming Language.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
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.
Graphical User Interface Programming Dr. Susan McKeever (not me)
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
IB Computer Science II Paul Bui
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
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.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
Java Virtual Machine Java Virtual Machine A Java Virtual Machine (JVM) is a set of computer software programs and data structures that use.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
1 Comp 104: Operating Systems Concepts Java Development and Run-Time Store Organisation.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
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-
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.
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Introduction and Features of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++
POS 406 Java Technology And Beginning Java Code
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
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.
By: Cheryl Mok & Sarah Tan. Java is partially interpreted. 1. Programmer writes a program in textual form 2. Runs the compiler, which converts the textual.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
JAVA Ekapap Julnonyang When it was implemented? Developed by Sun Microsystems. The first public implementation was Java 1.0 in 1995 The language.
CSCI 212 Object-Oriented Programming in Java. Prerequisite: CSCI 111 variable assignment statement while loop for loop post-increment (i++) strong typing.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
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.
Object Oriented Programming in
Before You Begin Nahla Abuel-ola /WIT.
Chapter 1 Introduction to Computers, Programs, and Java
Introduction to.
Internet and Java Foundations, Programming and Practice
Introduction Enosis Learning.
Introduction to Java Dept. Business Computing University of Winnipeg
Introduction Enosis Learning.
Getting Started ARCS Lab..
(Computer fundamental Lab)
IB Computer Science II Paul Bui
Introducing Java.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Computer Programming-1 CSC 111
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:

Introduction to Java Programming

Key Benefits of Java Java is “write once, run anywhere” architecture neutral portable across different platforms Due to Java Virtual Machine (JVM) Security features highly configurable security levels prevent any piece of Java code doing harm to the host system

Key Benefits of Java Network-centric platform Object Oriented easy to work with resources across a network and to create network based applications Object Oriented an interacting collection of independent software components dynamic extensible programs

Key Benefits of Java Internationalisation Performance uses 16 bit Unicode characters that represents the phonetic and ideographic character sets of the entire world Performance although an interpreted language Java programs run almost as fast as native C, C++ programs Simple and easy to develop powerful & well designed set of APIs

JVM Compiled by Java compiler Interpreted by JVM myCode.class Bytecode 1001100101001 … myCode.class Bytecode Compiled by Java compiler class myCode { … … } myCode.java Interpreted by JVM Source Code Application runs

JVM JVM provides the run time environment for the bytecode (Java Runtime Environment JRE) executes the bytecode and causes native machine code instructions to execute on the CPU that the JVM is on  each target platform needs an implementation of the JVM

Basic Program structure Basic class definition class className { // field declarations … // method declarations … } Each program needs a main method to tell the program where to start executing

Simple Java Program public class HelloWorld{ // no fields accessible to all classes (info hiding) Simple Java Program public class HelloWorld{ // no fields // main method public static void main (String [] args){ System.out.println("Hello World.."); } } command line args indicates class method returns nothing invoking a member

Objects An object includes state (fields) and behaviour (methods) A class object is the blueprint for the instance objects All code must be included in a class no inline functions like C++

reference to the object itself An Example Class a business class predefined Java class public class Student { // member fields String name; // constructor public Student(String name) { this.name=name; } // methods void printDetails(){ System.out.println("\nName: “ + name); } } no return type reference to the object itself String concatenation

Instantiation Class definition creates “class object” at runtime To instantiate “instance objects” use new operator ClassName myInstance = new ClassName(); where ClassName() is a constructor Note: no need to allocate the memory for the object like in C++

Using a Class in a Program the program control class source file called myProg.java public class myProg { public static void main(String args []){ // instantiate a Student object Student student= new Student("Joe Bloggs"); // invoke printDetails method student.printDetails(); } } case sensitive

Using the JDK Create source files for each class in your program The name of source file should be the same as the name of class public class myCode { … … } myCode.java Source File

Compiling your source code Compile each class source file into bytecode (class files) To compile a java source file javac myCode.java This creates a classfile called myCode.class 1001101001110101011 … myCode.class Class File

To run your program To start your program running you run the bytecode of the program control class The program control class has the main method To run bytecode – pass it to the JVM java classFileName e.g. java myProg note no .class included