Introduction. Overview of the Course on Java. Overview of Part 1 of the Course

Similar documents
Java Programming Language Mr.Rungrote Phonkam

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Introduction to Java

25. DECUS Symposium THE Application Development Environment for OpenVMS

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE

1 OBJECT-ORIENTED PROGRAMMING 1

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

[Course Overview] After completing this module you are ready to: Develop Desktop applications, Networking & Multi-threaded programs in java.

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Introduction... xv SECTION 1: DEVELOPING DESKTOP APPLICATIONS USING JAVA Chapter 1: Getting Started with Java... 1

IQTIDAR ALI Lecturer IBMS Agriculture University Peshawar

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Core Java SYLLABUS COVERAGE SYLLABUS IN DETAILS

Programming with Java

Lecture 1: Introduction to Java

Introduction to Java Programming

SELF-STUDY. Glossary

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

Core JAVA Training Syllabus FEE: RS. 8000/-

GETTING STARTED. The longest journey begins with a single step. In this chapter, you will learn about: Compiling and Running a Java Program Page 2

For live Java EE training, please see training courses at

CSE1720 Delegation Concepts (Ch 2)

You should now start on Chapter 4. Chapter 4 introduces the following concepts

J2EE Technologies. Industrial Training

Outline. Object Oriented Programming. Course goals. Staff. Course resources. Assignments. Course organization Introduction Java overview Autumn 2003

COURSE SYLLABUS. Complete JAVA. Industrial Training (3 MONTHS) PH : , Vazhoor Road Changanacherry-01.

CHAPTER 1. Introduction to JAVA Programming

Selected Java Topics

Table of Contents Fast Track to Java 8 EVALUATIONA COPY

Class List. Java Must Have. Class Goals. Class Goals. Schedule

CPSC 324 Topics in Java Programming

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

USING THE OOSIML/JAVA COMPILER. With the Command Window

JAVA: A Primer. By: Amrita Rajagopal

Component Based Software Engineering

Chapter 1 Introduction to Java

Advanced Java Programming

Contents. iii Copyright 1998 Sun Microsystems, Inc. All Rights Reserved. Enterprise Services August 1998, Revision B

Graphical User Interfaces (GUIs)

JAVA & J2EE UNIT -1 INTRODUCTION

Eng. Mohammed S. Abdualal

Packages: Putting Classes Together

Advanced Object-Oriented Programming Introduction to OOP and Java

Notes of the course - Advanced Programming. Barbara Russo

Lecture 1: Overview of Java

JAVA. Duration: 2 Months

1. What is Jav a? simple


Introduction to Java Written by John Bell for CS 342, Spring 2018

Java Professional Certificate Day 1- Bridge Session

Programming Language Concepts: Lecture 8

Chapter 13. Applets and HTML. HTML Applets. Chapter 13 Java: an Introduction to Computer Science & Programming - Walter Savitch 1

JAVA Training Overview (For Demo Classes Call Us )

Programming. Syntax and Semantics

Syllabus & Curriculum for Certificate Course in Java. CALL: , for Queries

Chapter 1 Introduction to Computers, Programs, and Java

Setup and Getting Startedt Customized Java EE Training:

Beyond CSE143. What s Left To Do? Templates. Using Templates. A Template Class. A Problem with Reusing Code CSE 143

GUI Forms and Events, Part II

Compaq Interview Questions And Answers

Java Swing Introduction

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

CS415 Human Computer Interaction

엄현상 (Eom, Hyeonsang) School of Computer Science and Engineering Seoul National University COPYRIGHTS 2017 EOM, HYEONSANG ALL RIGHTS RESERVED

CS 335 Lecture 02 Java Programming

Introduction to Java. Nihar Ranjan Roy.

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Introduction to Computers and Java

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

NetBeans IDE Java Quick Start Tutorial

CHAPTER 1 Introduction to Computers and Java

GUI Basics. Object Orientated Programming in Java. Benjamin Kenwright

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

Course Content for Java J2EE

Certified Core Java Developer VS-1036

Introduction to Computation and Problem Solving

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

JAVA PROGRAMMERS GUIDE LESSON

Class Libraries. Readings and References. Java fundamentals. Java class libraries and data structures. Reading. Other References

Swing from A to Z Using Focus in Swing, Part 2. Preface

Computational Applications in Nuclear Astrophysics using Java Java course Lecture 1

Core Java Syllabus. Pre-requisite / Target Audience: C language skills (Good to Have)

Part 3: Graphical User Interface (GUI) & Java Applets

Just Enough Eclipse What is Eclipse(TM)? Why is it important? What is this tutorial about?

Assumptions. History

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

Lesson 01 Introduction

CS Exam 1 Review Suggestions

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features

Lesson 04: Our First Java Program (W01D4

2/9/2012. Chapter One: Introduction. Chapter Goals

Introduction to JAVA Programming Language

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

CHAPTER 1: A GENERAL INTRODUCTION TO PROGRAMMING 1

Example Programs. COSC 3461 User Interfaces. GUI Program Organization. Outline. DemoHelloWorld.java DemoHelloWorld2.java DemoSwing.

G51PRG: Introduction to Programming Second semester Applets and graphics

Transcription:

Introduction Michael B. Spring Department of Information Science and Telecommunications University of Pittsburgh spring@imap.pitt.edu http://www.sis.pitt.edu /~spring Overview of the Course on Java Part 1: Java as strong language for: Cross platform development Graphical user interface development Object-oriented coding Part 2: Java for Web development Applets Servets JSP Part 3: Java for client-server development 02/08/2002 Introduction to Java 2 Overview of Part 1 of the Course Demystifying Java: Simple Code Introduction to Java An Example of OOP in practice Object Oriented Programming Concepts OOP Concepts -- Advanced Hints and for Java I/O (Streams) in Java Graphical User Interface Coding in Java Exceptions and Exception handling This slide set 02/08/2002 Introduction to Java 3 1

Overview of this Presentation Background understandings How to set your system up for Java How to prepare your editor How to Compile and Run a Java application A hello world type application A program with a graphical user interface Gathering systems information Some Java History and Terminology 02/08/2002 Introduction to Java 4 Background 02/08/2002 Introduction to Java 5 Background Overview This course anticipates that you: Have knowledge of at least one a structured programming language Have some understanding of object oriented design Have some familiarity with Graphical User Interface (GUI) programming 02/08/2002 Introduction to Java 6 2

Language Evolution The history of programming languages is a history of efforts to deal with every more complex programming task Linear atomic programming (machine coding) gave way to structured, and then modular, and then object based and oriented coding as mechanisms to deal with complexity. Object oriented languages use data hiding, attached methods, and inheritance to simplify the programming task 02/08/2002 Introduction to Java 7 Object Oriented Design Object oriented design makes use of objects, and actions on objects as a natural way of thinking about large complex objects. In addition, because graphical interfaces are naturally thought of as a large collection of objects, OOAD and OOP are naturals when working with interface intensive applications. Object oriented design requires a shift from procedurally controlled thinking about programs to an event driven model of programming where messages control the flow of information Keep in mind that in OOP, you need to assume your application exists in a sandbox that dispatches events 02/08/2002 Introduction to Java 8 GUI Intensive Programming When program involve the development of a Graphical User Interface (GUI), several new concerns are presented to the programmer: The program is represented as a set of windows Windows are either components or containers Components generate events which must be responded to Containers contain other containers or components and must have rules about layout A mapping must be created which describes how events generated by objects are to be handled 02/08/2002 Introduction to Java 9 3

Demystifying Java 02/08/2002 Introduction to Java 10 Setting up your environment (1) Load the JDK -- The JDK has two releases, Java1 and Java2 Java 1 is JDK 1.1.x Java 2 is JDK 1.2.x and 1.3 You want Java 2 which is radically different than Java 1 a self extracting zip file can be obtained from http://www.javasoft.com/j2se/1.3/ Extract the file to a directory like d:\jdk1.2 Follow the installation instructions available at the site: On NT and 2000 -- right click on MyComputer, select properties, and set the path variable to include the JDK bin directory -- in our example d:\jdk1.2\bin Win 98 -- edit c:\autoexec.bat and add the path to the end of the PATH command there Do the same for the CLASSPATH variable, also, be sure to add. to the CLASSPATH 02/08/2002 Introduction to Java 11 Setting up your environment (2) Load the JDK Documentation extract the file using win zip to the Java Directory -- in our example d:\jdk1.2 This will extract all the files to a docs subdirectory Provide for easy access to the documentation add the file d:\jdk1.2.2\docs\api\index.html to the bookmarks of your browser, or Add a shortcut to the document to your desktop this will allow quick access to the voluminous documentation 02/08/2002 Introduction to Java 12 4

Setting up an Editor (1) You have three choices for editing and compiling Java files Basic command line Context sensitive editor Full IDE Using the command line: edit a.java file (e.g. myclass.java) using notepad Open a command/dos window on the directory of the file compile the files using javac e.g. javac myclass.java will produce myclass.class interpret the resulting class file using java e.g. java myclass will run the program 02/08/2002 Introduction to Java 13 Setting up an Editor (2) Install your own editor (e.g. Realj) Follow the installation instruction It is best to install Realj after the JDK Make sure your classpath includes. Make sure Realj picked up the JDK location Check preferences Use the editor to write a program Note that it is context sensitive Compile and run the program from within the editor Sun makes an integrated development environment available It is called forte and available at: http://www.sun.com/forte/ffj/ce/download.html Its use is beyond the scope of this introduction. 02/08/2002 Introduction to Java 14 A First Code Example public class start{ public static void main(string[] args){ System.out.println( Starting Java"); } } one and only one main per application file must be named to match main class (start.java) the naming is case sensitive each class in.java file become separate.class files args is an object, thus no argc, arg.len instead arg[0] is the first parameter, not the executable System.out is a printstream (to the console) 02/08/2002 Introduction to Java 15 5

A Second Code Example note the use of imports to access predefined classes and methods note the subclassing of the JFrame from Swing note the implements to get a window listener note the use of methods Question How many class files will be produced? Where did the system object come from? What do you think setsize does and what do the numbers mean What pattern do you see in capitalization 02/08/2002 Introduction to Java 16 A Second Code Example import java.awt.event.*; // required for WindowListener import javax.swing.*; // required for JFrame public class Closingframe{ public static void main(string[] args) {BFrame x = new BFrame(); x.show();} } class BFrame extends JFrame implements WindowListener { BFrame() {settitle("a frame that listens"); setsize(200,200); addwindowlistener(this);} public void windowclosing(windowevent e) { System.exit(0); }[some code omitted here] } 02/08/2002 Introduction to Java 17 Learning About this Platform Java is a cross platform language, system information is made available through encapsulation. You should keep in mind the objects that encapsulate information One of the places where you can find system information is the Properties class The Java version and classpath The operating system name architecture, and version User's account name, home directory, and current working directory The Toolkit has some information about the screen Finally, the Graphics Environment has some information about fonts 02/08/2002 Introduction to Java 18 6

A Little Piece of Code import java.util.*; //for the Properties class import java.awt.*; //for GraphicsEnv and Toolkit public class properties{ public static void main(string[] args){ Properties p = System.getProperties(); p.list(system.out); GraphicsEnvironment GL = GraphicsEnvironment.getLocalGraphicsEnvironment( ); String[] fnts = GL.getAvailableFontFamilyNames(); for (int i=0;i<fnts.length;i++) {System.out.println(fnts[i]);} Toolkit TK = Toolkit.getDefaultToolkit(); Dimension scr_dim = TK.getScreenSize(); System.out.println(scr_dim.height); System.out.println(scr_dim.width); System.exit(0); } } 02/08/2002 Introduction to Java 19 A Challenge Exercise Can you improve this piece of code? See if you can find and read the documentation on the classes Toolkit in java.awt Properties in java.util GraphicsEnvironment in java. awt Is there any other environment data you can find? Can you figure out how to organize the data? Can you add some headers and formatting information? 02/08/2002 Introduction to Java 20 Java Terminology 02/08/2002 Introduction to Java 21 7

Overview of Terminology The history and roots and future of Java Concepts and Terminology Concept of class The Java Virtual Machine (JVM) Containers and components Other features of Java 02/08/2002 Introduction to Java 22 History The Java language has roots and four branches. The roots are C/C++ Embedded computing The Web The branches are Web Applications Cross Platform Development Advanced Network applications 02/08/2002 Introduction to Java 23 Roots The original project at Sun was called the Green project it was aimed at the development of a small language to control devices it used a C like language and depended on a virtual machine at the target as it ended up, intelligent consumer appliances have been slow to develop Java was designed to be a true object oriented language with C syntax most of the weaknesses of C have been removed -- e.g. pointers C++ structure has been improved upon -- interfaces The Web offered a new opportunity to market Java Java provided an opportunity for dynamic pages It offloaded the growing server burden Clients(browsers) were just right for virtual machines 02/08/2002 Introduction to Java 24 8

Branches Java the Application Development Language a cross platform language -- write once, run anywhere a mature object oriented language with a widely known syntax a rich class library to support sophisticated applications Remote Method Invocation Java DataBase Connectiveity (JDBC) Java Beans Java the Web Language secure applets authenticated servlets secure communications via SSL Java the Page Script Java the Next Generation -- JINI 02/08/2002 Introduction to Java 25 The Concepts of Class OOPL are based on Classes classes can be thought of as templates and as datatypes an instance of a class is an object the object is a complex variable an instance of the template or datatype in which specifics can be filled in Classes can be broadly or narrowly defined a account class is broader than an interest account class an interest account class is broader than a money market savings account or CD account a CD account class is broader than a CD - six month compounded interest account class or a CD-yearly compounded interest account class a subclass inherits the methods and fields of the parent and add additional specialize fields and methods 02/08/2002 Introduction to Java 26 Java Terminology related to Classes The data associated with a class are called fields The associated functions are called methods The methods which create new instances(objects) from a class are called constructors A Class is generally created by extending an existing class A Class may extend only one class. A Class may implement one or more special classes, called interfaces to add additional features. Classes are collected in groups called packages. A class or group of classes is made available to a program by importing the package 02/08/2002 Introduction to Java 27 9

The Java Virtual Machine The Java Virtual Machine (JVM) is a kind of software cpu that runs the compiled java program, translating the instructions into native CPU instructions As a result, several things occur: Java programs are compiled and have the potential to run very efficiently depending on the Java Virtual Machine Java programs can run on multiple platforms because the virtual machine translates the compiled program to native language the programs are considered secure in that the virtual machine can be restricted in which instructions it will translate 02/08/2002 Introduction to Java 28 Java Terminology related to the JVM The JDK is the Java Development Kit and it is distributed free of charge by SUN. The JDK consists of all the packages and tools needed to make Java programs The JDK tools used most frequently are: javac which is the java compiler which converts source code to byte code java which is the JVM distributed with the JDK -- also called the java interpreter appletviewer which is the JVM distributed with the JDK for interpreting applets jar which is the program to create and manage java archives -- collections of compiled classes 02/08/2002 Introduction to Java 29 Graphical User Interfaces(GUIs) Java is used to develop graphical user interfaces The interface is an important component of many applications Java has a rich set of classes and to support development of the user interface Because of the speed with which Java was adopted, both the classes that are used for the interface objects and the events which occur have undergone very rapid and dramatic evolution Some of what was developed historically is no longer considered to be valid -- it is deprecated 02/08/2002 Introduction to Java 30 10

Java Terms related to the GUI The Java package for graphical user interface components prior to Java 1.2 was java.awt While some classes from java.awt continue to be used, GUI classes are now found in javax.swing Events that occur in interface objects are handled by methods that are called listeners There are about a dozen listeners defined in java.awt.event. They include WindowListener and ActionListener These event classes are implemented for a class that is defined in Java 02/08/2002 Introduction to Java 31 Other Java Developments and Terms the fact that Java source code compiles to a separate bytecode file made it hard to share code (especially for applets) a JAR file -- Java ARchive makes sharing sets of compiled files easier. (An archive is simply a Unix name for a zip file) JavaBeans are visual components that can be used in a standard way in apps. Traditionally, they are visual components that can simply be dropped into an application. 02/08/2002 Introduction to Java 32 Other Java Developments and Terms (continued) Remote Method Invocation or RMI is the Java name for a set of classes that enable the user to develop client-server applications with a greater focus on the functional rather than the communications design. JDBC allows database connections much like those allowed by ODBC. JINI, pronounced "Genie" is the newest development. It is intended to extend RMI so that devices can find each other and register services in a network environment. It is like a glorified plug and play capability. 02/08/2002 Introduction to Java 33 11