Presentation is loading. Please wait.

Presentation is loading. Please wait.

UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 4 HW#1: Electronic Submission of Part 2 Jini.

Similar presentations


Presentation on theme: "UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 4 HW#1: Electronic Submission of Part 2 Jini."— Presentation transcript:

1 UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 4 HW#1: Electronic Submission of Part 2 Jini Overview (continued) C++ Diagnostic Results Java Fundamentals Wed. 9/13/00

2 Electronic Submission of Homework #1, Part 2 Mon, 9/18 “Hello World” programming (application and applet) (application and applet) Homework is due at the start of lecture on the due date. Note: If you want to use Swing on HW#1 in UML CS UNIX environment, use the Java version located in: /usr/opt/java122/bin /usr/opt/java122/bin/javac /usr/opt/java122/bin/javac /usr/opt/java122/bin/java /usr/opt/java122/bin/java Entire class will transition to this Java version starting with HW#2. Entire class will transition to this Java version starting with HW#2.

3 Electronic Submission of Homework #1, Part 2 Mon, 9/18 “Hello World” programming (application and applet) (application and applet) Homework is due at the start of lecture on the due date. To submit your files electronically, use the UNIX submit command Example for 3 files: Example for 3 files: submit kdaniels hw1 filename.java filename.class filename.html submit kdaniels hw1 filename.java filename.class filename.html You’ll submit 5 files for HW#1, part 2: 2 for application, 3 for applet You’ll submit 5 files for HW#1, part 2: 2 for application, 3 for applet Submission deadline is 9:30 a.m. on Monday, 18 September Submission deadline is 9:30 a.m. on Monday, 18 September I have now set it up to allow multiple submissions before the deadline I have now set it up to allow multiple submissions before the deadline Bring a paper printout of your code to give to me at start of Monday’s lecture Bring a paper printout of your code to give to me at start of Monday’s lecture

4 Jini Overview (continued)

5 Requirements for Service, Client ä Either you or a delegate must be able to: ä Connect to a TCP/IP network ( ) ä Participate in discovery to find a Lookup Service ä Register with a Lookup Service to provide proxy ä Keep leases current ä Participate in discovery to find a Lookup Service ä Communicate with a Lookup Service to receive service proxy To be a Jini Service: To be a Jini Client: Extra “machinery” needed: - http server(s) for each machine to offer up downloadable code - RMI activation daemon

6 Hello World in a Jini Setting... c: policy.all policy corejinichapter5 HelloWorldServiceInterface.javaHelloWorldService.javaHelloWorldClient.java client HelloWorldServiceInterface.classHelloWorldClient$Listener.classHelloWorldClient.class corejinichapter5 HelloWorldServiceInterface.classHelloWorldServiceProxy.classHelloWorldService$Listener.classHelloWorldService.class corejinichapter5service service-dl HelloWorldServiceProxy.class corejinichapter5

7 Who Else is in the Game? (other providers of coordination frameworks/connection technologies/service architectures for distributed computing) ä HAVi ä Sony, Sharp, Toshiba, Philips, RCA, Matsushita, Hitachi, Grundig ä Microsoft & HP ä ChaiAppliance Plug and Play ä eSpeak ä Universal Plug and Play ä Network protocol level ä XML device description ä Salutation Framework

8 Further Information – Jini ä Sun web sites ä http://www.javasoft.com/jini http://www.javasoft.com/jini ä http://www.jini.org http://www.jini.org ä Development – Books ä “Core Jini” by W. Keith Edwards ä “The Jini Specification” by Arnold, O’Sullivan, Scheifler, Waldo, and Wollrath ä Gartner Advisory: ä Java Jini: A ‘Killer-App Enabler’ for Network Computing? http://gartner.jmu.edu/research/ras/83000/83044/83044.html portions of this slide contributed by Ayal Spitz

9 C++ Diagnostic Results Number of Students 1716151413121110987654321 Question Number 1 2 3 4 5 6 7 8 9 NumberofCorrectResponses Most students ran out of time…

10 Java Fundamentals ä 1: Java fundamentals ä applets, applications, data types, control structures, OO programming, files ä 2: Advanced Java concepts & Java support for distributed computing ä GUI/events, graphics, exceptions, advanced data structures, threads/ multithreading, RMI ä 3: Distributed computing using a sample Java- based environment: Jini

11 Syllabus for Part 1 of the Course Closed book; Worth 15% of grade

12 Why Java & Distributed Computing? ä Platform independence helps with heterogeneous hardware, software challenge ä Built-in support for: ä Multithreading: “concurrent” multiple activities ä Client-Server computing: servlets, JDBC ä Remote Method Invocation (RMI): method calls across network ä Networking: socket-based communication views networking like file I/O For insight into the original Java vision, see the original Java whitepaper by James Gosling at: http://java.sun.com/people/jag/OriginalJavaWhitepaper.pdf

13 C to C++ to Java: At a Glance C Primitive Data Types Arrays Struct, Union, Enum Preprocessor Directives OperatorsExpressions Control Statements FunctionsPointers Dynamic Memory Mgt File I/O Exception Handling JavaC++ Primitive Data Types Arrays Struct, Union, Enum Preprocessor Directives OperatorsExpressions Control Statements FunctionsPointers Dynamic Memory Mgt File I/O Exception Handling Classes Multiple Inheritance PolymorphismTemplates uu Primitive Data Types Arrays OperatorsExpressions Control Statements Dynamic Memory Mgt File I/O Exception Handling Classes, Interfaces Inheritance InheritancePolymorphism Support for DBs, networks, GUIs, events, graphics, threads, libraries Procedural, Compiled Language Procedural/OO, Compiled Language OO, Interpreted Language

14 Introduction to Java Applications ä Java application is executed using the Java interpreter (but not inside browser like an applet) ä Application begins execution in main( ) ä main( ) is static method inside class ä no convenient input from command line ä System.exit(0); // required to clean up // after GUI/graphics // after GUI/graphics // Save this in file Welcome1.java public class Welcome1{ public static void main( String args[] ) public static void main( String args[] ) { System.out.println( "Java is fun!" ); System.out.println( "Java is fun!" ); }} javac Welcome1.java java Welcome1 Welcome1.class Welcome1.java

15 javac Welcome1Applet.java appletviewer Welcome1Applet.html Introduction to Java Applets ä Java applet is executed inside a WWW browser (or appletviewer) using a Java interpreter that is inside the browser. Welcome1Applet.class Welcome1Applet.java Welcome1Applet.html // Save this file in Welcome1Applet.java import java.applet.*; import java.awt.*; public class Welcome1Applet extends Applet{ public void paint(Graphics g) public void paint(Graphics g) { g.drawString( "Java is fun!”, 25, 50 ); g.drawString( "Java is fun!”, 25, 50 ); }} <HTML> </APPLET></HTML> Save this file in Welcome1Applet.html

16 Introduction to Java Applets (continued) ä Order of (a subset of) applet method invocations: ä init( ) ä start( ) ä paint( )

17 Java Variables ä Two types: ä primitive data type variable (a.k.a. variable) ä always passed by value ä initialized by default to 0 if numeric; false if boolean ä except for local variables ä value is constant if final keyword is used ä reference variable (a.k.a. reference) ä refers to memory location of object ä always passed by reference ä initialized by default to null

18 Java Primitive Data Types

19 Java Array Class ä Declarations: ä One-dimensional: ä int c [ ]; c = new int [8]; ä int c [ ] = new int [8]; ä final int ARRAY_SIZE = 8; int c [ ] = new int [ARRAY_SIZE]; ä int c [ ] = { 32, 44, 6, 7, -1, 25, 88, -31 }; ä Multi-dimensional (e.g. 2): ä int c[ ][ ] = { {32, 44, 6, 7 }, {-1, 25, 88, -31} }; ä int c[ ][ ] = new int[2][4]; ä int c[ ][ ] = new int[2][ ]; // allocate rows for non-rectangular array ä c[0] = new int[3]; // allocate columns for row 0 ä c[1] = new int[4]; // allocate columns for row 1 ä Knows its own length! (e.g. c.length) ä Bounds are checked for you!

20 Java String Class (basics) ä String is a series of characters treated as a single unit ä Declarations and Constructors: ä String s; // empty string for now -- its length is 0 ä s = new String(); // String() is null constructor. It yields an empty // string for now whose length is 0 ä s = new String(“hello”); // initializes s to “hello” ä String s = “hello”; // initializes s to “hello” ä s2 = new String (s1); // copy constructor ä String s = “hello” + “ world”; // String concatenation ä s1.equals (s2); // tests equality of contents ä s1 = = s2 // tests if both refer to same object in memory ä Knows its own length! (e.g. s.length) ä Array of Strings: String Pets[ ] = {“dog”, “cat”, “fish”};

21 Some Java Operators [Deitel, p. 271; complete list is in Appendix C] Precedence: Operator higher up the chart is evaluated before operator lower down the chart Associativity: Order of evaluation for operators of equal precedence

22 Expressions ä Sequence of operators and operands that specifies a computation ä May result in a value (e.g., 123, true) ä May cause side-effects (e.g., change a value) ä Compound expressions (e.g., (a*b)+c)) ä Includes literals (numbers or strings)

23 Java Expression BNF expression ::= numeric_expression | testing_expression | logical_expression | string_expression | bit_expression | casting_expression | creating_expression | literal_expression | "null" | "super" | "this" | identifier | ( "(" expression ")" ) | ( expression ( ( "(" [ arglist ] ")" ) | ( "[" expression "]" ) | ( "." expression ) | ( "," expression ) | ( "instanceof" ( class_name | interface_name ) ) ) ) From http://cuiwww.unige.ch/db-research/ Enseignement/analyseinfo/BNFweb.html

24 Statements ä Smallest “executable” unit ä Declaration statements ä Control statements ä Assignment statements ä Method invocation ä Compound statement (block) ä Semicolon-separated list of statements ä Enclosed in “curly” brackets { } ä Deitel calls it a ‘block’ only if it has declarations of its own

25 Java Abstract Windowing Toolkit GUI Components (from java.awt package) ä java.awt.Graphics (see list on p. 530-531) ä Given an object g of Graphics class: ä g.setColor( Color.red ); // Sets current drawing color to red ä g.drawString(“hello”, 200, 25); // Draws String starting at (200,25) ä g.drawLine(20, 28, 40, 10 ); // Draws line from (20,28) to (40,10) ä g.fillRect(100, 5, 20, 15); // Draws filled rectangle whose upper left // corner is at (100, 5). Width = 20. Height = 15 // corner is at (100, 5). Width = 20. Height = 15 ä g.drawOval(60, 9, 20, 13); // Draws oval whose bounding box upper left // corner is at (60, 9). Width = 20. Height = 13 // corner is at (60, 9). Width = 20. Height = 13 (0,0)x y hello usescurrentcolor

26 Java Swing GUI Components (from javax.swing package) ä javax.swing.JOptionPane ä Dialog box ä message ä error ä information ä warning ä question ä plain ä input ä javax.swing.JTextArea ä javax.swing.JScrollPane


Download ppt "UMass Lowell Computer Science 91.460 Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 4 HW#1: Electronic Submission of Part 2 Jini."

Similar presentations


Ads by Google