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.

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

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
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999.
Introduction to Java.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
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.
Marlene Galea.  The JDK (Java Development Kit)  An IDE (Integrated Development Environment) ◦ Different IDEs include:  JCreator  NetBeans  BlueJ.
CMSC 202 Computer Science II for Majors Fall 2009 Introduction.
Developing User Interfaces (DUI) Chris North cs3724: HCI.
Suma D Event Driven programming using java(CSE210) Overview of java Packages and interface Exception handling Multithreading Input/output.
Advanced OOP MCS-3 OOP BSCS-3 Lecture # 1
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
Lecturer PEN PHIROM Tel : Web site: Lecturer PEN PHIROM Tel :
Programming Fundamentals 2: Background/ F II Objectives – –give a non-technical overview of Java Semester 2, Background.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Introduction to Programming Languages. Problem Solving in Programming.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
Why Java? A brief introduction to Java and its features Prepared by Mithat Konar.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
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,
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
POS 406 Java Technology And Beginning Java Code
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
Java Tutorial Ethan New York University.
Applets. What is an applet? Why create applets instead of applications? – Applets are Java programs that can be embedded in an HTML document – In contrast,
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.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Introduction to Java The Java Platform, The Java Language, JDK, Eclipse Svetlin Nakov Technical Trainer Software University
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
We will talking about story of JAVA language. By Kristsada Songpartom.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java -- A very Hot Object- Oriented Language Instructors: Fu-Chiung Cheng ( 鄭福炯 ) Associate Professor Computer Science & Engineering Tatung Institute of.
The Java Platform, The Java Language, JDK, IntelliJ
CSI 3125, Preliminaries, page 1 Applet. CSI 3125, Preliminaries, page 2 Applet An applet is a Java program that runs in a Web browser. An applet can be.
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.
Introduction to Programming 1 1 2Introduction to Java.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
Introduction to JAVA Programming
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
Applications Active Web Documents Active Web Documents.
Object Oriented Programming in
Before You Begin Nahla Abuel-ola /WIT.
A Programming Language for Web-based Computing with Graphics
Chapter 1 Introduction to Computers, Programs, and Java
Introduction Enosis Learning.
Introduction to Java Dept. Business Computing University of Winnipeg
Introduction Enosis Learning.
Getting Started ARCS Lab..
A Programming Language for
(Computer fundamental Lab)
F II 1. Background Objectives
Introducing Java.
Review of Previous Lesson
A Programming Language for
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

Contents 1. Java, etc. 2. Java's Advantages 3. Java's Disadvantages 4. Types of Java Code 5. Java Bytecodes 6. Steps in Writing a Java Application 7. Steps in Writing a Java Applet

1. Java, J2SE, JSDK, JDK, JRE There are several 'Java' names:  Java is the name of the language Java 2 is the current version  the language + tools (e.g. compiler) is called J2SE, the Java 2 Standard Edition J2SE is the current version its also known as J2SE 6.0 continued the same thing

JSDK  stands for "Java Software Development Kit  JDK is the old name for JSDK  don't be surprised to also see J2SDK or Java SDK continued

JSDK contains all the libraries (packages), compiler, and other tools for writing/running/debugging Java code. JRE = "Java Runtime Environment"  a cut-down version of JSDK with only the packages/tools needed for running Java code  most often used by Web browsers

More New Names Sun is trying to get people to drop the "2" from the Java platform names.  e.g. J2SE becomes Java Standard Edition, abbreviated as "Java SE"  not really popular, yet

2. Java’s Advantages Productivity  object orientation  many standard libraries (packages) Simpler/safer than C, C++  no pointer arithmetic, has automatic garbage collection, has array bounds checking, etc. continued

GUI features  mostly located in the Swing and Abstract Windowing Toolkit (AWT) packages Multimedia  2D and 3D graphics, imaging, animations, audio, video, etc. continued

Network support  communication with other machines/apps  variety and standards: sockets, RMI, CORBA  security, resource protection Multithreading / concurrency  can run several ‘threads’ at once continued

Portablility / Platform Independence  “write once; run anywhere”  only one set of libraries to learn J2SE is free continued

Good programming environments:  Eclipse, Blue J, JBuilder, NetBeans, Sun One Studio  do not use them when first learning Java  Applets (and Java Web Start) eliminates the need for explicit software installation. continued

3. Java’s Disadvantages Java/J2SE is still being developed  many changes between versions Sun has not guaranteed backward compatibility of future versions of Java.  at the moment, when old-style code is compiled, the compiler gives a “deprecation” warning, but will still accept it continued

Java compilation/execution was slow, but...  not any more: J2SE 1.5 is the same speed as C (perhaps a tiny bit slower for some things)  there are compilers to native code, but they destroy the “write one; run anywhere” idea  the first version of Java, back in 1995, was about 40 times slower than C continued

Slow Internet connections  makes it difficult (and irritating) to download medium/large size applets  e.g. GIF89a/flash files have replaced Java animations Lots to learn  Java language (small) and Java libraries (very, very large) continued

4. Types of Java Code There are two kinds of Java code: 1. Java applications  ordinary programs; stand-alone  they don’t run inside a browser (but they can use Java’s GUI libraries) continued We will see examples in the next part.

2. Java applets  they run in a Web browser  they are attached to Web pages, so can be downloaded easily from anywhere  applets have access to browser features

5. Java Bytecodes The Java compiler ( javac ) generates bytecodes  a set of instructions similar to machine code  not specific to any machine architecture A class file (holding bytecodes) can be run on any machine which has a Java runtime environment.

The Bytecode Advantage Java code (.java file) javac (Windows) javac (Mac) javac (Linux) Java bytecode (.class file) Java runtime (Windows) Java runtime (Mac) Java runtime (Linux)

6. Steps in Writing a Java Application Foo.java text file holding the application javac Foo.java call the Java compiler Foo.class class file holding Java bytecodes java Foo execute the class using the Java runtime system (the JVM)

Hello.java import java.io.*; public class Hello { public static void main(String args[]) { System.out.println(“Hello Andrew”); } } // end of class

Compile & Run

7. Steps in Writing a Java Applet AFoo.java text file holding the applet javac AFoo.java call the Java compiler AFoo.class class file holding Java bytecodes appletviewer AFoo.html AFoo.html Web page that calls AFoo.class execute the applet using the Java runtime system (the JVM)

AFoo.classAFoo.html Web page that calls AFoo.class browser downloads Web page and Java class Using a browser For Java 2, the Java Plug-in is required, or use the Opera browser

WelcomeApplet.java import javax.swing.JApplet; import java.awt.Graphics; public class WelcomeApplet extends JApplet { public void paint(Graphics g) { g.drawString(“Welcome Andrew”, 25,25); } }

WelcomeApplet.html Applet Testing

Compile & Run $ javac WelcomeApplet.java $ appletviewer WelcomeApplet.html

Browser Execution Microsoft IE and Netscape do not directly support Java 2. A common solution is to use the Java plugin, available from Sun  a drawback is that it requires the Web page containing the applet to contain more complicated tags (and JavaScript code) so that the applet can run inside Netscape and Microsoft IE continued

A better solution is to use the Opera browser:  free from  it comes with JRE 1.5, the latest version of the Java Runtime Environment, or it can be linked to the JRE already on your machine  there is no need for a Java plugin  Opera is very fast, small-size, and supports many networking standards continued

Load WelcomeApplet.html