1 Chapter 3 Programs and Packages. 2 Java Virtual Machine (JVM) Java programs execute on the JVM. The JVM is a virtual rather than a physical machine,

Slides:



Advertisements
Similar presentations
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Advertisements

In Review JAVA C++ GUIs - Windows Webopedia.com.
JSP1 Java Server Pages (JSP) Introducing JavaServer Pages TM (JSP TM ) JSP scripting elements.
Lab#1 (14/3/1431h) Introduction To java programming cs425
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
Object Orientated Programming
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999.
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.
1 Introduction to Java and Applet Lecture 3 from Chapters 1 and 2 of the complete reference.
1 Build a Web Application on J2EE. 2 J2EE Scenario Client – Web Server – EIS Resources Client – Web Server – EIS Resources Client – Application Server.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
1 Chapter 2 Introductory Programs. 2 Getting started To create and run a Java program –Create a text file with a.java extension for the source code. For.
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.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
Java Software Solutions Lewis and Loftus Chapter 2 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Software Concepts -- Introduction.
INTRODUCTION TO WEB DATABASE PROGRAMMING
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
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.
M1G Introduction to Programming 2 4. Enhancing a class:Room.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
CSC Java Programming, Spring, 2014 Welcome to Java Programming. Tuesday, January 21, 2014.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Introduction to JavaServer Pages (JSP) Slides from Dr. Mark Llewellyn.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Introduction to the Java Virtual Machine 井民全. JVM (Java Virtual Machine) the environment in which the java programs execute The specification define an.
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.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
JAVA Java is a programming language and computing platform first released by Sun Microsystems in It was first developed by James Gosling at Sun Microsystems,
© 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
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
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.
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)
CT1513 Introduction To java © A.AlOsaimi.
Class Libraries Chapter 1 1 Source Intro to Java Programming Y. Daniel Liang.
23-October-2002cse JavaIntro © 2002 University of Washington1 Intro to Java CSE 413, Autumn 2002 Programming Languages
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
A compiler is a computer program that translate written code (source code) into another computer language Associated with high level languages A well.
Java 3 More Java Then Java. Libraries & Packages Java standard class library is composed of useful classes that help us to achieve our programming goals.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Creating a Java Application and Applet
Java – in context Main Features From Sun Microsystems ‘White Paper’
1 Introduction Read D&D Sec 1.8; Sec 1.13 THE Java tutorial -
CSC Java Programming, Fall, 2008 August 28, 2008, class 2 Tuesday, September 2 uses Monday’s schedule!
Java Packages - allow you to group classes as a collection Standard Java library has packages: java.lang and java.util … Also hierarchical: java and javax.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Applications Active Web Documents Active Web Documents.
Before You Begin Nahla Abuel-ola /WIT.
CSC Java Programming, Spring, 2010
(Computer fundamental Lab)
Chap 1. Getting Started Objectives
CSC Java Programming, Spring, 2009
Chap 4. Programming Fundamentals
CSC Java Programming, Spring, 2013
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
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:

1 Chapter 3 Programs and Packages

2 Java Virtual Machine (JVM) Java programs execute on the JVM. The JVM is a virtual rather than a physical machine, although the JVM has been implemented in silicon. The JVM is typically implemented as a run- time interpreter that translates Java bytecode instructions into native instruction codes, which the host platform executes.

3 Java Virtual Machine (JVM) The java utility in the JDK provides the JVM as a run-time interpreter. The JVM provides a run-time environment (runtime for short) that enables programs to execute on a host platform. The Java runtime can work with a security manager to determine which operations a program can perform on the host platform.

4 Program types Java has four program types, although the differences among them are shallow. The four types are: –Application –Applet –Servlet –Bean

5 Application type An application is a standalone program in the sense of requiring only the JVM to execute. An application does not require a host program such as a browser. An application has main as its entry point.

6 Applet type An applet in the original sense is a small program typically downloaded from a server to a client machine. A Web browser equipped with a JVM typically acts as the host program for an applet. An applet is typically launched through an HTML or equivalent document.

7 Applet type An applet typically operates under a strict security manager, which imposes sandbox security. Such security prevents an applet from performing potentially dangerous operations such as reading from or writing to the local disk. An applet’s class descends from the standard Applet class.

8 Servlet type A servlet is a program that executes on a server machine, typically to process a request submitted from a client machine. A servlet’s host program is typically a Web server, which provides a JVM. A servlet, like an applet, is typically launched from a Web browser but, unlike an applet, executes on the server.

9 Servlet type A servlet commonly performs database operations and generates dynamic Web content to displayed on a client’s browser. A servlet’s class either implements the standard Servlet interface or descends from a class that implements this interface.

10 Bean type A bean is a software component, that is, a prebuilt software part that can be integrated with others to build an application. A bean typically has a distinct, special purpose. Examples are calendar beans, login beans, beans, and so forth. A bean’s class or an ancestor implements the standard Serializable interface.

11 Summary of program types A given piece of Java code could, in principle, belong to each program type. –Every applet is automatically a bean, for instance. The key point is that the very same programming constructs are available throughout the program types.

12 Packages Files with a.class extension are aggregated into packages, or collections of related classes. Packages may contain subpackages to arbitrary levels. The primary package is java and its main subpackage is lang.

13 Packages All classes in the java.lang package are automatically imported into every program. Programmers typically import classes from packages to avoid using fully qualified names. If a program imports the class java.util.Date, the programmer then can use Date instead of the fully qualified name.

14 Packages The java and the javax packages are standard packages. –The javax packages are e x tensions to the earlier java packages. The standard packages support string and text processing, numeric computation, networking, graphics, security, and so on.

15 Packages Packages can be used to resolve name conflicts. –The java.awt package has a List class and the java.util package has a List interface. The fully qualified names java.awt.List java.util.List disambiguate.

16 Packages Every class belongs to a package. The package to which a class belongs can be explicitly declared with the package statement in a source file. A class belongs to a default unnamed package if a containing package is not explicitly declared.

17 package statement The package statement, if present, occurs as the first uncommented line in a source file. –The source file Hi.java could begin package hiPkg; // Note: 1st line import java.util.Date; class Hi {...

18 CLASSPATH Variable Utilities such as the compiler and the run- time interpreter can find standard packages and the classes contained therein. The CLASSPATH environment variable can be set so that these utilities can find programmer-defined classes in their containing packages, whether explicitly named or default.

19 Subdirectories as subpackages A hierarchical file system with directories and subdirectories can be used to implement packages and subpackages. Suppose that directory MAIN contains a subdirectory SUB. A source file in MAIN could treat SUB as a subpackage and import all of the classes therein with the command import SUB.*;

20 Summary of packages Packages are a convenient way to group related classes into software libraries. Standard packages such as java.math do precisely this. For small programs and projects, default packages are typically sufficient. Explicitly named packages are especially useful for large projects with many programmers.