1 / 33

Java Outline

Java Outline. Intro and Applications Applets and GUI Client / Server RMI, JDBC. Background. Objective: Platform independent C++ 1991 - 1994 Oak 1994 - JAVA Virtual Machine / Interpreter. Java “Buzzwords”. Simple Object-Oriented Network-Savy Robust Secure Architecture neutral

ossie
Download Presentation

Java Outline

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Java Outline • Intro and Applications • Applets and GUI • Client / Server • RMI, JDBC CS423 (cotter)

  2. Background • Objective: Platform independent C++ • 1991 - 1994 Oak • 1994 - JAVA • Virtual Machine / Interpreter CS423 (cotter)

  3. Java “Buzzwords” Simple Object-Oriented Network-Savy Robust Secure Architecture neutral Portable Interpreted High Performance Multi-threaded Dynamic CS423 (cotter)

  4. JAVA Implementation Java program Java program Java program Java program Java Cmds Java Cmds Java Cmds VM VM VM SPARC PowerPC Intel CS423 (cotter)

  5. Extension to Internet • Timing with Internet growth • Same functionality needed • Just implement a new tag (applet) • Browser loads web page & applet CS423 (cotter)

  6. Operations Environments • Applications program (~DOS window) • supports file access • Applet (browser) • supports Internet linkages. CS423 (cotter)

  7. Object Oriented Concepts • Intent is to model the environment • Combine attributes with functions CS423 (cotter)

  8. Play Wave Data Stop whatever... Characteristics Current track Record OO Structure(audio clip) CS423 (cotter)

  9. OO vs. Procedures function function function function Global Data Play Play clip Audio Player Wave Data whatever... Stop stop Characteristics Current track record clip Record CS423 (cotter)

  10. OO Concepts • Inheritance • Integer • Myinteger (with min and max fields) • Method Overloading • public String(char value[]); • public String(char value[], int offset, int count); • Polymorphism • public int hashCode(); CS423 (cotter)

  11. OO Class Relationships • use (call a method, etc.) • containment (“has-a”) • inheritance (is-a”) CS423 (cotter)

  12. OO Structure • class • data • public • private • methods • constructor • destructor • others CS423 (cotter)

  13. Java Structure class HelloApplication { public static void main (String argv[]) { String message[] = new String[2]; message[0] = "Welcome to CS490D"; message[1] = "The subject is JAVA!"; System.out.println (message[0]); System.out.println (message[1]); } } CS423 (cotter)

  14. Java Support Environments • JDK 1.0.2, JDK 1.1.4, JDK 1.2.2 • Borland JBuilder • Semantic Cafe • just-in-time compiler • Visual J++ • etc. CS423 (cotter)

  15. Java Info Sources • http:/java.sun.com • The home for Java • http://www.gamelan.com/ • central repository for info • MANY others. CS423 (cotter)

  16. Java Language Structure - Packages (1.0.2) • java.lang - basic classes (objects, strings, threads, etc.) • java.io - stream mgmt for files, strings, other sources • java.util - time, rand, generic data struct.. • java.net - URLs, TCP, UDP, IP, binary to text • java.awt - manages user interface components • java.awt.image - manage image data • java.awt.peer - platform specific implementation links • java.applet - Applet class, interfaces to resources CS423 (cotter)

  17. java.lang • Object • Process • Runtime • Thread • Math • String • Integer • etc…… CS423 (cotter)

  18. java.lang.Object public class java.lang.Object { // Constructors public Object(); §1.12.1 // Methods protected Object clone(); §1.12.2 public boolean equals(Object obj); §1.12.3 protected void finalize(); §1.12.4 public final Class getClass(); §1.12.5 public int hashCode(); §1.12.6 public final void notify(); §1.12.7 public final void notifyAll(); §1.12.8 public String toString(); §1.12.9 public final void wait(); §1.12.10 public final void wait(long timeout); §1.12.11 public final void wait(long timeout, int nanos); §1.12.12 } CS423 (cotter)

  19. java.lang.integer public final class java.lang.Integer extends java.lang.Number (I-§1.11) { // Fields public final static int MAX_VALUE; §1.8.1 public final static int MIN_VALUE; §1.8.2 // Constructors public Integer(int value); §1.8.3 public Integer(String s); §1.8.4 CS423 (cotter)

  20. java.lang.integer // Methods public double doubleValue(); §1.8.5 public boolean equals(Object obj); §1.8.6 public float floatValue(); §1.8.7 public static Integer getInteger(String nm); §1.8.8 public static Integer getInteger(String nm, int val); §1.8.9 public static Integer getInteger(String nm, Integer val); §1.8.10 public int hashCode(); §1.8.11 public int intValue(); §1.8.12 public long longValue(); §1.8.13 public static int parseInt(String s); §1.8.14 public static int parseInt(String s, int radix); §1.8.15 public static String toBinaryString(int i); §1.8.16 public static String toHexString(int i); §1.8.17 public static String toOctalString(int i); §1.8.18 public String toString(); §1.8.19 public static String toString(int i); §1.8.20 public static String toString(int i, int radix); §1.8.21 public static Integer valueOf(String s); §1.8.22 public static Integer valueOf(String s, int radix); §1.8.23 } CS423 (cotter)

  21. Building Java Applications Using Java Development Kit • Get a copy of the JDK (java.sun.com, etc.) • Install the development kit (tools and classes) • Create MyApp.java source file • text editor (notepad, etc.) • winedit, Café, etc. • Compile .java file to create .class file • javac MyApp.java • Run application (.class file) through java VM • java MyApp CS423 (cotter)

  22. Sample Java App G:\Data\Java\MyHelloApp>type MyHelloApp.java class MyHelloApp { public static void main (String argv[]) { String message[] = new String[2]; message[0] = "Welcome to CS423"; message[1] = "The subject is JAVA!"; System.out.println (message[0]); System.out.println (message[1]); } } CS423 (cotter)

  23. Sample Java App G:\Data\Java\MyHelloApp>javac MyHelloApp.java G:\Data\Java\MyHelloApp>java MyHelloApp Welcome to CS423 The subject is JAVA! G:\Data\Java\MyHelloApp> CS423 (cotter)

  24. Add Interaction with User class ParmApplication { public static void main (String argv[]) { int i; if (argv.length == 0) { System.out.println (""); System.out.println (" Put parameters on the " + "command line. Here is the syntax:"); CS423 (cotter)

  25. Add Interaction with User System.out.println (""); System.out.println ("java ParmApplication Parm0 " + "Parm1 Parm2 [...]"); System.out.println (""); System.exit (1); } System.out.println (""); System.out.println (" " + argv.length + " string parameter(s) entered:"); CS423 (cotter)

  26. Add Interaction with User for (i = 0; i < argv.length; i++) { System.out.println ( " Parm #" + i + ": --->" + argv[i] + "<---" ); } System.out.println (""); } } CS423 (cotter)

  27. Add interaction with user G:\ParmApplication>javac ParmApplication.java G:\ParmApplication>java ParmApplication Put parameters on the command line. Here is the syntax: java ParmApplication Parm0 Parm1 Parm2 [...] G:\ParmApplication>java ParmApplication first 2nd 35 3 string parameter(s) entered: Parm #0: --->first<--- Parm #1: --->2nd<--- Parm #2: --->35<--- G:\ParmApplication> CS423 (cotter)

  28. Get Input from User import java.io.*; class InputApp { InputApp () { DataInputStream dis = new DataInputStream (System.in); String sIn = " "; String sOut = " "; File fIn; File fOut; FileInputStream fis; FileOutputStream fos; int iNumBytesRead; byte[] ab; CS423 (cotter)

  29. Get Input from User System.out.println ("*-------------------------------------------*"); System.out.print ("Enter Source File Name Here: "); System.out.flush (); try {sIn = dis.readLine ();} catch (Exception e) {System.out.println ("Exception on input file name" + e);} System.out.print("Enter Destination File Name Here: "); System.out.flush (); try {sOut = dis.readLine ();} catch (Exception e) {System.out.println ("Exception on output file name" + e);} CS423 (cotter)

  30. Get Input from User try { fIn = new File (sIn); fis = new FileInputStream (fIn); fOut = new File (sOut); fos = new FileOutputStream (fOut); ab = new byte[2048]; while ((iNumBytesRead = fis.read (ab)) != -1) { fos.write (ab, 0, iNumBytesRead); } fis.close (); fos.close (); } catch (Exception e) {System.out.println ("Exception during copy: " + e); } CS423 (cotter)

  31. Get Input from User System.out.println ("Data copied from " + sIn + " to " + sOut); System.out.println ("*-------------------------------------------*"); } public static void main (String args[]) { new InputApp (); } } CS423 (cotter)

  32. Get Input from User G:\Data\Java\InputApp>java InputApp *-------------------------------------------* Enter Source File Name Here: books_db.txt Enter Destination File Name Here: My_list.txt Data copied from books_db.txt to My_list.txt *-------------------------------------------* G:\Data\Java\InputApp> CS423 (cotter)

  33. Java Inheritance (extension)- awt • Object - “cosmic base class” • Component - button, listBox • Container - dialog box • Panel - “sub-window”, group of buttons, etc. • Applet - small application, web enabled • MyApplet - specific instance of an applet CS423 (cotter)

More Related