Introduction to Java. 2 Module Information Programming conceptsPrerequisites Beginners in JAVATarget Audience This module will provide you a solid grounding.

Slides:



Advertisements
Similar presentations
A Programmer's Introduction to Java - from a S/370 user (c) IDMS/SQL News
Advertisements

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.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Object Orientated Programming
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.
Introduction to Java.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
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.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
Sadegh Aliakbary Sharif University of Technology Fall 2011.
BASIC JAVA PROGRAMMING TUTORIAL. History  James Gosling and Sun Microsystems  Oak  Java, May 20, 1995, Sun World  Hot Java –The first Java-enabled.
+ 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)
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
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.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
1.  At the end of this slide, student can:  Explore tools, features, properties and interface of the Textpad.  Creating a new project.  Open and run.
Sadegh Aliakbary Sharif University of Technology Fall 2012.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
The Basics of Javadoc Presented By: Wes Toland. Outline  Overview  Background  Environment  Features Javadoc Comment Format Javadoc Program HTML API.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
POS 406 Java Technology And Beginning Java Code
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Java Introduction 1. Introduction to Java Programming2 Computers and Computer Languages Computers are everywhere –how many computers do you own? Computers.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Session 1 Introduction to Java. Objectives Java Simplified / Session 1 / 2 of 32 Explain the history of Java Explain Java in brief List the types of Java.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
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.
Copyright © Mohamed Nuzrath Java Programming :: Syllabus & Chapters :: Prepared & Presented By :: Mohamed Nuzrath [ Major In Programming ] NCC Programme.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
What is Java? Object Oriented Programming Language Sun Microsystems “Write Once, Run Everywhere” Bytecode and Virtual Machine Java Platform (Java VM and.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
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.
Java Programming: Advanced Topics1 Introduction to Advanced Java Programming Chapter 1.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Introduction to Programming 1 1 2Introduction to Java.
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.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction to JAVA Infobizzs.com.
Object Oriented Programming in
Chapter 1 Introduction to Computers, Programs, and Java
Chapter No. : 1 Introduction to Java.
Introduction to Advanced Java Programming
Internet and Java Foundations, Programming and Practice
An Overview of Java.
Introduction to Java Dept. Business Computing University of Winnipeg
Advanced Programming Fall 2017.
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
(Computer fundamental Lab)
Java History, Editions, Version Features
Chap 1. Getting Started Objectives
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

2 Module Information Programming conceptsPrerequisites Beginners in JAVATarget Audience This module will provide you a solid grounding to start learning the Java language Course Description

3 1.0 Introduction Introduction: After completing this chapter, you will get a good understanding about JAVA. Objectives: After completing this chapter, you will be able to explain, History of Java Why is JAVA Important? Types of Programs in JAVA Security & Portability Byte Code Features of JAVA PATH and CLASSPATH Class and Object JAVAP JavaDoc Java API

4 Birth of C -A structured, efficient high-level language. -C is a programmers language. -A powerful, efficient, structured language that was relatively easy to learn The Need for C++ -Why C++ -Complexity History of Java

5 OOP – OOP is a programming methodology that helps Organize complex programs through the use of inheritance, Encapsulation and polymorphism. History of Java

6 The creation of Java -Java was conceived by James Gosling, Patrick Naughton, -Chris Warth, Ed Frank, and Mike Sheridon at Sun Microsystems in Original impetus of java was not the Internet. -Primary Motivation for developing java -Need for Platform Independent (Architecture neutral) Language. Platform Independence To produce code that could run on a variety of CPU’s under differing environments. History of Java

7 Since different types of CPU, are used as controllers. The trouble with C, C++ is that they are designed to be compiled for a specific target. Platform independence – A high profile necessity Finally – Java not an internet version of C++. Java is to internet programming and c was to systems Programming. History of Java

8 Why is JAVA Important? Why java important to the internet ? Java expands the universe of objects that can move about freely in cyberspace. In a network two categories of objects are transmitted between the server and the client. 1. Passive information. 2. Active programs. Passive Information – Reading a . Active programs - A dynamic self executing program. For ex: A program to display the properly in the clients Machine. – Applet.

9 Types of Programs in JAVA Java Applets and Application. Java can be used to write two types of programs. -Application -Applet Applet : An applet is an application designed to be transmitted over the internet and executed by a Java Compatible web browser. Applet can react to user input and dynamically change. Two Fundamental Problems –Security –Portability

10 Security & Portability Security : –Fear of viral infection –Fear of malicious program Java answers both of these concerns by providing a firewall between a networked application and your computer. Java achieves this protection by confining a java program to the Java execution environment and not allowing it access to other parts of the computer. Portability : For programs to be dynamically downloaded to all the various types of platforms connected to the Internet, some meansof generating portable executable code is needed.

11 Byte Code The key that allows Java to solve both the security and the portability problems is that the output of a java compiler is not executable code rather it is Byte code. Byte code is a highly optimized set of instructions designed to be executed by the Java run-time system, which is called the Java Virtual Machine (JVM). Translating a java program in a wide variety of environments.The reason is only the JVM needs to be implemented for each platform. * Remember the details of JVM will differ from Platform to Platform

12 Features of JAVA –Simple –Secure –Portable –Robust –Multithreaded –Architecture –neutral –Interpreted and high performance –Distributed –Dynamic.

13 Robust –To better understand how java is robust consider two of the main reasons for program failure. –Memory Management mistakes and mishandled exceptional conditions. Ex. Garbage cleaning division by zero error file not found etc. Architecture - Neutral –“Write once, run anywhere,any time for ever.” Features of JAVA

14 Distributed –Java is designed for the distributed environment of the Internet because it handles TCP/IP protocols. –Accessing a resource using URL is not much different from accessing a file. ** Allowing objects on two different computers to execute procedures remotely (RMI Remote method invocation )‏ Features of JAVA

15 PATH and CLASSPATH Two separate environment variables with separate functions ClassPath: Environment Variable Consists of : –Directories, –JAR files, and –ZIP files –Separated by a path separator character (";")‏ Entry in the CLASSPATH represents: –A location from which the Java runtime will search for classes when it needs to load them.

16 If your classpath contains jars,zip etc.. these have to be added explicitly to the class path PATH: Determines where your system will look for executable programs when they are named on the command line Understanding “PATH”: Consider that we have a javac.exe executable - this javac.exe helps us to compile the java files. Let us assume that this exe is not in the PATH. Let this be placed under c:/jdk/bin; Place a java file Test.java under c:/jdk/bin Go to your command prompt and go to c:/jdk/bin Now type javac Test.java. Your java file will be compiled. PATH and CLASSPATH

17 Now place the Test.java under c: Go to your command prompt and type javac Test.java Your java file will not be compiled, the system will say that javac is not recognized. This is because the file is not in your PATH. PATH and CLASSPATH

18 Class and Object Class and Object: Consider a rubber stamp - this represents a class Name and class - represents the properties of the class Now if i use this rubber stamp on a notebook, this stamped image represents an object(i.e, instance of the rubber stamp). Now you can fill in the name and class property with your name and class. So you can create 'n' number of objects. Finally, –Class - just a template –Object - a template with filled in details

19 Class and Object

20 In the above case - the properties name and class are the attributes of that class. For accessing these variables we can define methods in a class, like getName(); setName(); - these are methods in class. By default a class will have a default constructor. This constructor is responsible for creating a new object. Ex: RubberStamp myLabel = new RubberStamp()‏ now this new keyword actually calls the default constructor of rubber stamp to get an instance of the class (i.e.. object)‏ Class and Object

21 JAVAP Disassembles a class file. Output depends on the options used. If no options are used, javap prints out the public fields and methods of the classes passed to it. javap prints its output to stdout.

22 Ex: class C { static int a = 1; static int b = 2; static { System.out.println(a); } static { a++; b = 7; System.out.println(a); System.out.println(b); } static { System.out.println(b); } public static void main(String args[]) { C c = new C(); } JAVAP

23 When the resulting class C is passed to javap using no options the following output results: Compiled from C:\users\dac\C.java private class C extends java\lang\Object { static int a; static int b; public static void main(java\lang\String []); public C(); static void (); } JAVAP

24 -l : Prints out line and local variable tables. -p : Prints out the private and protected methods and fields of the class in addition to the public ones. -c : Prints out disassembled code, i.e., the instructions that comprise the Java byte codes, for each of the methods in the class. JAVAP

25 JavaDoc Parses the declarations and doc comments in Java source files and formats the public API into a set of HTML pages. As an argument to javadoc you can pass in either a package name or a list of Java source files. The package specified on the command line must be in your CLASSPATH. Note that javadoc uses.java files not.class files. javadoc reformats and displays all public and protected declarations for, –Classes and Interfaces –Methods –Variables

26 begin with /** and indicate text to be included automatically in generated documentation. An example of a class comment: /** * A class representing a window on the screen. * For example: * * Window win = new Window(parent); * win.show(); * awt.BaseWindow awt.Button Dec 1994 Sami Shaio */ class Window extends BaseWindow {... } JavaDoc

27 Java API The Java Application Programming Interface (API) is prewritten code, organized into packages of similar topics. For instance, the Applet and AWT packages include classes for creating fonts, menus, and buttons. The full Java API is included in the Java 2 Standard Edition download. API Documentation Building an Application For Complete on-line documentation for version of Java: Refer : java.sun.com/j2se/1.4.2/docs/api/

28 Summary OOP is a programming methodology that helps Organize complex programs through the use of inheritance, Encapsulation and polymorphism. Java can be used to write two types of programs. -Application -Applet Simple, secured and portable CLASSPATH - A location from which the Java runtime will search for classes when it needs to load them. PATH - Determines where your system will look for executable programs when they are named on the command line. Class - just a template Object - a template with filled in details JAVAP - Disassembles a class file. Javadoc - Parses the declarations and doc comments in Java source files and formats the public API into a set of HTML pages.

29 Test Your Understanding Why is Java a known as a platform independent Language? What is a byte code verifier? What is the difference between PATH and CLASSPATH? Are these only for Windows OS? What is an object? What is a class disassembler? What is an API?