Java Programming Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen Feburary 2006.

Slides:



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

1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Lab#1 (14/3/1431h) Introduction To java programming cs425
The road to reliable, autonomous distributed systems
The Java Language. Topics of this Course  Introduction to Java  The Java Language  Object Oriented Programming in Java  Exceptions Handling  Threads.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Introduction to Java The objectives of this chapter are: To describe the key aspects of Java To describe the Java software development kit (SDK) To explain.
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.
Java Programming Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen September 2003.
Introduction to Java Kiyeol Ryu Java Programming Language.
Java Programming Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen Feburary 2007.
CS2200 Software Development Lecture: Java Platform Lecturer: Adrian O’Riordan Course Webpage:
For more Lectures and Notes Visit
CS884 (Prasad)Java Goals1 “Perfect Quote” You know you've achieved perfection in design, Not when you have nothing more to add, But when you have nothing.
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.
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
1 CSC 551: Web Programming Spring 2004 Java Overview  Design goals & features  platform independence, portable, secure, simple, object-oriented, … 
Introduction to Java Programming. Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps.
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.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Lecturer PEN PHIROM Tel : Web site: Lecturer PEN PHIROM Tel :
About the Java  Java technology is both a programming language and a platform –The Java Programming Language A high-level language that can be characterized.
Programming Fundamentals 2: Background/ F II Objectives – –give a non-technical overview of Java Semester 2, Background.
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
Enterprise Java v120131Intro to JavaEE1 Java EE 5 TM Introduction.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
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 Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen Feburary 2013.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
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.
Java and its Evolution. Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java Environment.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
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.
1. An Introduction A Programming Language A Technology Java Development Kit Java API One Language: Three Editions Standard Edition Enterprise Edition.
Java Programming Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen September 2001.
What is Java? Object Oriented Programming Language Sun Microsystems “Write Once, Run Everywhere” Bytecode and Virtual Machine Java Platform (Java VM and.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
1 Introduction to Java. 2 * 10% Assignments/ class participation * 10% Pop Quizzes * 05% Attendance * 25% Mid Term * 50% Final Term.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Web Design & Development Lecture 2. Intro to Java.
Introduction to JAVA Programming
Java Programming Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen Feburary 2011.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Object Oriented Programming in
Introduction to Java Programming
Chapter 1 Introduction to Computers, Programs, and Java
Chapter No. : 1 Introduction to Java.
Introduction Enosis Learning.
Introduction Enosis Learning.
(Computer fundamental Lab)
Java History, Editions, Version Features
Introducing Java.
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:

Java Programming Transparency No. 1-1 Introduction to Java Programming Cheng-Chia Chen Feburary 2006

Java Programming Transparency No. 1-2 Course web page

Java Programming Transparency No. 1-3 Lecture 1. Introduction Cheng-Chia Chen

Java Programming Transparency No. 1-4 Contents 1.What is Java? 2.Features of Java 3.History of Java 4.Develop first Java program 5.Deploy java programs through the internet 1.via Java applet 2.via Java Web Start

Java Programming Transparency No. 1-5 What is Java? Java is  a programming language, defined in The Java language specification (v1,v2,v3)The Java language specification  a virtual machine, Defined in The java virtual machine (v1, v2)The java virtual machine  a platform Standard edition (j2se): Java 2 platform standard edition 5.0 Enterprise edition(j2ee): V1.4, V5.0 soon. Micro edition (j2me): v1.0,CLDC1.1,MIDP2.0,…

Java Programming Transparency No. 1-6 Java 2 Platform editions and their target markets servers & enterprise computers Desktop & personal computers High-end consumer devices Low-end devices smartcards J2ME

Java Programming Transparency No. 1-7

Java Programming Transparency No. 1-8 What is J2EE ?  source source  What is the Java 2 Platform, Enterprise Edition (J2EE)? a platform that enables solutions for developing, deploying and managing multi-tier server-centric applications. Extend J2SE to a complete, stable, secure, fast Java platform to the enterprise level. A platform which significantly reduces the cost and complexity of developing multi-tier solutions, results in services that can be rapidly deployed and easily enhanced.

Java Programming Transparency No. 1-9 Benefits of J2EE 1. Complete Web services support. 2. Faster solutions delivery time to market. Enterprise infrastructure and concerns provided and solved by j2ee. Developers need only focus on writing business logic. 3. Freedom of choice. System assembled from standard components which can be supplied by various vendors. 4. Simplified connectivity. Supply standard to connect legacy systems, enterprise information system, and bring capability to web and mobile devices. 5. Reduce TCO(total cost of ownership) and avoid single-source for software needs of enterprises.

Java Programming Transparency No Technologies included in J2EE  Java API for XML-Based RPC (JAX-RPC),  JavaServer Pages, Java Servlets,  Enterprise JavaBeans components,  J2EE Connector Architecture,  J2EE Management Model,  J2EE Deployment API,  Java Management Extensions (JMX),  J2EE Authorization Contract for Containers,  Java API for XML Registries (JAXR),  Java Message Service (JMS),  Java Naming and Directory Interface (JNDI),  Java Transaction API (JTA),  CORBA, and  JDBC data access API.

Java Programming Transparency No What is J2ME ?  1.What is the Java 2 Platform, Micro Edition (J2ME)?J2ME The Java TM 2 Platform, Micro Edition is the edition of the Java 2 platform targeted at consumer electronics and embedded devices. The J2ME technology consists of a virtual machine (KVM) and a set of APIs suitable for providing tailored runtime environments for consumer and embedded electronics.  Configurations v.s. profiles  Device characteristics: memory size / processor size and depth of display screen (UI) power consumption (battery-based) networking capability (limited, not TCP/IP based?)

Java Programming Transparency No Features of the java language: Java is  simple  object-oriented  distributed  interpreted  robust  secure  architecture-neutral  portable  high performance  multithreaded  dynamic

Java Programming Transparency No Java is Simple  Intentionally created to be syntactically similar to C/C++  Eliminates traditionally troublesome features of C/C++ Pointer arithmetic Multiple inheritance Implicit type coercions Explicit memory management Preprocessor  Eliminates features of C/C++ struct typedef union enum (recovered in jdk5.0) (Programmer controlled) operator overloading  Features included as part of base language: Threads Exception handling

Java Programming Transparency No Java is Object-oriented  Systems are built from sets of classes  Classes are instantiated at runtime to give objects  Objects communicate via messages passing  Everything is part of a class  supported OO Concepts: Data abstraction and Encapsulation Inheritance Polymorphism Dynamic Binding e.g. variable of Object type can hold everything  Logical cluster of classes == package

Java Programming Transparency No Java is a Distributed language  Network programming support built into JDK class library: TCP sockets UDP packets IP addresses URLs RMI (Remote Method Invocation) Web Service  Security features designed into language  Network programming facilities are one of the language's best features.

Java Programming Transparency No Java is an Interpreted language  Source code is initially compiled ( javac ) into architecture-neutral byte-codes  Byte-codes are interpreted by the java virtual machine (JVM) ( java or Netscape)  Dynamic linking/loading (at run time)  (Just In Time) JIT compilers lead to a large performance increase in compilation and runtime execution

Java Programming Transparency No Java is Robust  Strongly-typed language (cf Smalltalk and VisualBasic)  Compile-time and runtime checking  No pointer arithmetic  Exception handling  Automatic memory management

Java Programming Transparency No Java is secure  Designed with security in mind.  Allow users to download untrusted code over a network and run it in a secure environment in which it cannot do any harm.  Configurable security levels and restrictions.  subjected to intense scrutiny by security experts with [potentially serious ] bugs found and fixed. become a big news if new bugs found!!  One of the best mainstream platforms with the strongest security guarantee.

Java Programming Transparency No Java is Architecture-neutral  Byte-codes are architecture neutral  Performance suffers by using bytecodes

Java Programming Transparency No Java is portable  Primitive type sizes are explicit - not architecture dependent  Strings and characters are (16-bit) Unicode compliant easier for internationalization.  GUI libraries give a native graphic library- independent mechanism for creating quality graphical interfaces (sort of) "They gave us a library that is good for writing programs that look equally mediocre on the different systems." (Core Java, page 9)

Java Programming Transparency No High performance  Interpreting leads to quicker development cycle  Depends what you compare it to "Slightly faster than VB" - (Core Java, page 9) JITC(Just-In-Time Compiler) help greatly in this respect Sun’s Java HotSpot is Newest high performace JIT compiler.  Can use native code for mission-critical performance sections of code JNI: Java Native Interface Sacrifice portability.

Java Programming Transparency No Multithreaded  Based on well-known 20 year old Hoare monitor synchronization  Thread support built into language  Thread synchronization primitives supplied  Garbage collector runs permanently as a low priority background thread

Java Programming Transparency No Dynamic  Class linking, layout, name resolution and object references not resolved until run-time  Runtime Type Information (RTTI) available Can check the type of objects at run-time java.reflect.* package  Class class for dynamic instantiation Can create objects of types unkown until runtime. String sexClassName = getSex(); Object p = Class.forName(sexClassName).instance(); If(p instanceof Male) {…} else if (p instanceof Female) { … } else {… }

Java Programming Transparency No An Example /** * The HelloJava class implements an application that * simply displays "Hello Java!" to the standard output. */ class HelloJava { public static void main(String[] args) { // Display "Hello Java!" System.out.println("Hello Java!"); }

Java Programming Transparency No History of Java  Green Project (1990) Consumer device operating software Requirements: small size, robust, portable, extremely reliable,real- time performance  Oak Originally used C++, then realized a new language was needed Original requirements same as for current language  Java (1993) Intended market never eventuated WWW starting to takeoff Language design "based on" many current OO languages (e.g., C++, Eiffel, Smalltalk, Cedar/Mesa, Objective C) 1995/5/23 Sun launched Java JDK 1.0 released early 1996/1/23 ( 212 classes / 8 pkgs)

Java Programming Transparency No History of Java  1997 … 2/18: Complete JDK1.1 released (504 classes / 23 packages ) 3/28: JDK1.1.1, 5/28: JDK1.1.2, 7/2: JDK1.1.3,…  1998: 9/28: JDK1.1.7, 12/8: J2SE (1,520 classes / 59 packages )  1999: 6/? J2ME 12/7 J2EE  2000 j2se 1.3 (1,842 classes / 76 packages. )  2001 J2SE (2,991 classes / 135 packages )  /30 j2se 5.0 (3562 classes/ 166 packages )

Java Programming Transparency No Develop your first Java Program and applet 1. Required software 2. Creating Your First Application a. Create a Java Source File b. Compile the Source File c. Run the Program d. invoke the program remotely via Java Web Start. 3. Creating Your First Applet a. Create a Java Source File b. Create related HTML files c. Compile and run the Source File

Java Programming Transparency No Required Softwares To write your first program, you will need: 1. The Java TM 2 Platform, Standard Edition. 2. A text editor. Ex:  NotePad,  Ultraedit,  EditPlus2

Java Programming Transparency No Creating Your First Application  The first program, HelloWorldApp, will simply display : “Hello World!".  Steps: a. Create a Java source file. > Notepad HelloWorldApp.java b. Compile the source file into a bytecode file. > javac HelloWorldApp.java c. Run the program contained in the bytecode file. >java HelloWorldApp d. invoke the program remotely via Java Web Start. d.1 :> jar cf HelloJWS.jar HelloWorlApp.class d.2 : prepare HelloJWS.jnlp d.3 : prepare web page to hyperlink HelloJWS.jnlp

Java Programming Transparency No HelloJava.java /** * The HelloWorldApp class implements an application that * simply displays "Hello World!" to the standard output. */ class HelloWorldApp { public static void main(String[] args) { // Display "Hello World!" System.out.println("Hello World!"); }

Java Programming Transparency No. 1-31

Java Programming Transparency No JWS Architecture

Java Programming Transparency No (web page) d. Invoke Java application remotely via JWS <jnlp spec="1.0" codebase=" all/jws/" href="helloJWS.jnlp"> Hello Java Web Start Cheng-Chia Chen A simpe Demo of Java Web Start. HelloJWS.jar … Start HelloJWS … example

Java Programming Transparency No Java 2 SDK Installation Instructions (for WIN32) 1. Download java 2 SDK standard edition 2. Run the Java 2 SDK executable (*.exe). determine where to install j2se. (ex: c:\java\jdk5.0) > set JAVA_HOME= c:\java\jdk Update the PATH variable so that you can type ‘java’ instead of ‘c:\java\jdk5.0\bin\java’ to invoke java tools. > path=%JAVA_HOME%\bin;%PATH% 4. Check the CLASSPATH variable Used by java tools to determine where to find your personal (nonsystem) java class files Types of java byte codes (class files):  System : java tools know where to find them.  Extensions: put in %JAVA_HOME%\jre\lib\ext  Personal: via CLASSPATH or –cp/–classpath options 5. Start using the Java 2 SDK tools! java, javac, javadoc, jdb, javap,…

Java Programming Transparency No Creating Your First Applet a. Create a Java Source File: HelloJavaApplet.java import java.applet.*; import java.awt.*; /** * The HelloJavaApplet class implements an applet that * simply displays "Hello World!". */ public class HelloJavaApplet extends Applet { public void paint(Graphics g) { // Display "Hello Java Applet!" g.drawString("Hello world!", 50, 25); }

Java Programming Transparency No b. Create an HTML file to contain the applet. A Simple Program Here is the output of my program: <APPLET CODE="HelloJavaApplet.class" CODEBASE=“./applets/” WIDTH=250 HEIGHT=25> The applet does not work!  Save this code to a file called HelloJavaApplet.html.

Java Programming Transparency No c. Compile and run the program  Compile the Source File. Javac HelloJavaApplet.java  Run the program: With Appletviewer: appleviewer HelloWorld With IE explorer, Netscape: double click HelloJavaApplet.html  demo demo