Java Tutorial Ethan New York University.

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

CSci 1130 Intro to Computer Programming in Java
In Review JAVA C++ GUIs - Windows Webopedia.com.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 3.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Java Applet & JavaScript SNU OOPSLA Lab. October 2005.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
got ? Research Project – April 1998 Hang Xia, Mark Wang, Richard S. Chang Updated: R Norman, August 1999.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Java Applets. Road Map Introduction to Java Applets Review applets that ship with JDK Make our own simple applets –Introduce inheritance –Introduce the.
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.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
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.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Introduction to Java Programming with JBuilder 4
NSF North Mississippi GK-8 Program ‘Til You Drop Brenteria Travis NSF North Mississippi GK-8.
CS413: Java Programming language Applications Applets
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.
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Programming Fundamentals 2: Background/ F II Objectives – –give a non-technical overview of Java Semester 2, Background.
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.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Why Java? A brief introduction to Java and its features Prepared by Mithat Konar.
Computer Programming 12 Mr. Jean March 19 th, 2013.
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
Java Applet Presented by: Feng Liu. Agenda Introduction Java Applet vs. JavaScript Steps in Creating a Java Applet Java Applet Example Do I have to write.
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.
Introduction to HTML Tutorial 1 eXtensible Markup Language (XML)
9/21/99www.cs.vt.edu/wwtut/1 User Interface Programming In Java Part 1 – Introduction Marc Abrams Virginia Tech CS Dept courses.cs.vt.edu/wwwtut/
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
Clement Allen, PhD Florida A&M University SUMMER 2006.
The Joy of Programming (also known as) Introduction to Object-Oriented Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
Introduction to Java Programming. Introduction Course Objectives Organization of the Book.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Java applets. Outline What is Java? Java Applications Java Applets Java Applets Securities Summary.
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.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Mini University July, 2005 A Little Taste of Java (but don’t tell your folks) (they might think there’s caffeine involved)
Java and its Evolution. Contents Java Introduction Java Features How Java Differs from other OO languages Java and the World Wide Web Java Environment.
Applets Yong Choi School of Business CSU, Bakersfield.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
introductory lecture on java programming
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.
Lesson 5 MULTIMEDIA. Multimedia on the Web has expanded rapidly as broadband connections have allowed users to connect at faster speeds. Almost all Web.
ITP 109 Week 2 Trina Gregory Introduction 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.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Applications Active Web Documents Active Web Documents.
User Interface Programming In Java
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
Chapter 1 Introduction to Computers, Programs, and Java
Object Oriented Programming
UCSC All rights reserved
Introduction Enosis Learning.
Introduction Enosis Learning.
Introduction to Computing Using Java
Java Applets.
Introduction to Applet, Application and JDK
Java Evolution Java History. Java Features.
Introducing Java.
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
APPLET PROGRAMMING.
Presentation transcript:

Java Tutorial Ethan New York University

Road Map n What is Java? n Why is Java Important? –Strengths, Weaknesses n Java Tutorial: Creating an Applet n Cool Examples/Demos n Future of Java

I. What is Java? n Java is a new Internet programming language. n Developed by Sun Microsystems, Inc. n Originally developed for Interactive Television Set-top boxes. n Rapidly becoming the standard for Internet programming.

Evolution of the Web n Phase 1: Everything was in text. Used mainly by academics and government. n Phase 2: Simple, graphical user interface. –Mosaic and Netscape. –Used by millions of people. n Phase 3: Interactive Applications and Web Pages. –Where we are today.

Applets n Applets: mini Java applications that can be embedded inside a web page. Clock Applet Big Text Smaller Text

Some Basic Examples n Scrolling Ticker n “Bouncing Heads” n Simple Video Games

II. Why is Java Important? n Enables the distribution of applications across the Internet. n As a language, Java also has many important strengths: –Object Oriented –Built-in Security –Built-in Networking –Platform Independent –Built-in Multithreading

Feature #1: Object Oriented n Object Oriented languages enable the creation of large applications that are easy to maintain. Clock Object Scrolling Ticker Object Weather Object

Feature #2: Built-In Security n If you download an application across the Internet, the program might do malicious things: deleting files, reading sensitive data, etc.. Operating System: Read, write, delete files Java Security Sandbox Restricted Access

Feature #3: Networking n It is extremely easy to create network applications in Java. n Java was built from the ground up to work with the Internet.

Feature #4: Portable n Java is Platform independent: Runs on any platform - Windows, Macintosh, UNIX. n “Write once, run anywhere.” n Create a single application and it can run anywhere on the Internet.

Feature #5: Multithreading n You can create applications that do more than one thing at a time. n For example, you can have an animation and a sound at the same time. n Important for animations and network applications.

Java Virtual Machine C/C++ Program Operating System Java Virtual Machine Operating System Java Applet

Java Performance n The Achilles Heal of Java n When Java was first released, it was about 20 times slower than native applications written in C/C++. n Now, it’s about half the speed of C/C++. But, it really depends on the Browser and the Platform.

III. Java Tutorial n Once you understand the basics of Java, creating an Applet is straightforward. n In order to create an applet, you first need to download a Java Compiler. –Download the Java Development Kit (JDK) 1.1 from java.sun.com

Object Oriented Basics n Every object has two things: –Some Data –Some Methods (or functions) n For example, a scrolling ticker object might have: –The Text to be displayed. –A method called animate() that tells the object to start scrolling.

The Applet Object n The Applet objects contains: –Data regarding the Web Browser. –Methods for creating applications. n Some methods: –getImage ():Retrieves an image –paint ():Paint on a canvas –getAudioClip():Retrieves a sound file

Hello World! import java.applet.*; import java.awt.*; // This applet prints Hello public class FirstApplet extends Applet { // The method paints the applet public void paint (Graphics g) { g.drawString ("Hello, World!", 25, 50); }

Import/Comments n Import statement tells the Compiler to load certain libraries: –similar to the #include statement in C. –import java.applet.*; –import java.awt.*; (Abrstract Windowing Toolkit. Useful for using widgets and graphics) n Comments are denoted with // –// This is a comment.

Extending Applet n public class FirstApplet extends Applet { n This tells the compiler that you want to create an Applet object. Called FirstApplet. n This really relates to object oriented inheritance (which we don’t have time to discuss.)

Drawing Graphics n paint method: –Responsible for all graphics painting inside the applet. n g.drawString (“Hello World”, 25, 50); X Coordinate Y Coordinate

To View your Applet n First you need to compile your applet: –javac FirstApplet.java n Then, you need to create a simple HTML page:

Hello World, Version 2.0 import java.applet.*; import java.awt.*; // This applet prints Hello, Version 2.0 public class SecondApplet extends Applet { // The method paints the applet public void paint (Graphics g) { g.setColor (Color.pink); g.fillOval (10,10,330,100); g.setColor (Color.black); g.drawOval (10,10,328,100); g.setFont (new Font("Helvetica", Font.BOLD, 48)); g.drawString ("Hello, World", 40, 75); }

To View the Second Applet n HTML Page:

IV. Cool Examples n The Molecule Viewer: – n Wired Stock Graphing Tool: – n 3D Ray: – attJava480x300.html n Games: – cartman/cartman.htm

The Future of Java n To answer this question, you have to look at two elements: –What can you do with Java? What kind of added functionality will we see? –Where can you actually run Java? What comes after the Applet?

Java 1.2 n Current Release: Java 1.2 (Beta) Most browsers only support Version 1.0 n What’s new in Java 1.2: –Java Foundation Classes (Swing) –Java 2D, 3D –Java Sound –Java Speech

Java Everywhere n Java can run on any platform. n Embedded Java: –Java Rings –Java Smart Cards –Java Telephones –Java Televisions –Java light switches

One Java or Many? n Sun wants Java to be an open standard that can run on any platform. n Microsoft hates Java. Has created a slightly different version that is optimized for Windows.