Java Outline - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

Java Outline

Description:

Java Outline Intro and Applications Applets and GUI Client / Server RMI, JDBC Background Objective: Platform independent C++ 1991 - 1994 Oak 1994 - JAVA Virtual ... – PowerPoint PPT presentation

Number of Views:195
Avg rating:3.0/5.0
Slides: 34
Provided by: BobCo54
Category:

less

Transcript and Presenter's Notes

Title: Java Outline


1
Java Outline
  • Intro and Applications
  • Applets and GUI
  • Client / Server
  • RMI, JDBC

2
Background
  • Objective Platform independent C
  • 1991 - 1994 Oak
  • 1994 - JAVA
  • Virtual Machine / Interpreter

3
Java Buzzwords
  • Simple Object-Oriented
  • Network-Savy Robust
  • Secure Architecture neutral
  • Portable Interpreted
  • High Performance Multi-threaded
  • Dynamic

4
JAVA Implementation
Java program
Java program
Java program
Java program
Java Cmds
Java Cmds
Java Cmds
VM
VM
VM
SPARC
PowerPC
Intel
5
Extension to Internet
  • Timing with Internet growth
  • Same functionality needed
  • Just implement a new tag (applet)
  • Browser loads web page applet

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

7
Object Oriented Concepts
  • Intent is to model the environment
  • Combine attributes with functions

8
OO Structure(audio clip)
9
OO vs. Procedures
function
function
function
function
Global Data
Play
Play clip
Audio Player
Wave Data
whatever...
Stop
stop
Characteristics
Current track
Record
record clip
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()

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

12
OO Structure
  • class
  • data
  • public
  • private
  • methods
  • constructor
  • destructor
  • others

13
Java Structure
class HelloApplication public
static void main (String argv)
String message new String2 message0
"Welcome to CS490D" message1 "The
subject is JAVA!" System.out.println
(message0) System.out.println
(message1)
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.

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

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

17
java.lang
  • Object
  • Process
  • Runtime
  • Thread
  • Math
  • String
  • Integer
  • etc

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

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
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
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

22
Sample Java App
G\Data\Java\MyHelloAppgttype MyHelloApp.java class
MyHelloApp public static void main
(String argv) String
message new String2 message0
"Welcome to CS423" message1 "The
subject is JAVA!" System.out.println
(message0) System.out.println
(message1)
23
Sample Java App
G\Data\Java\MyHelloAppgtjavac MyHelloApp.java G\
Data\Java\MyHelloAppgtjava MyHelloApp Welcome to
CS423 The subject is JAVA! G\Data\Java\MyHelloAp
pgt
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")

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")
26
Add Interaction with User
for (i 0 i lt argv.length i)
System.out.println ( " Parm "
i " ---gt"
argvi "lt---" )
System.out.println ("")
27
Add interaction with user
G\ParmApplicationgtjavac ParmApplication.java G\
ParmApplicationgtjava ParmApplication Put
parameters on the command line. Here is the
syntax java ParmApplication Parm0 Parm1
Parm2 ... G\ParmApplicationgtjava
ParmApplication first 2nd 35 3 string
parameter(s) entered Parm 0
---gtfirstlt--- Parm 1 ---gt2ndlt---
Parm 2 ---gt35lt--- G\ParmApplicationgt
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
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)
30
Get Input from User
try fIn new File (sIn) fis
new FileInputStream (fIn) fOut new File
(sOut) fos new FileOutputStream (fOut)
ab new byte2048 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)
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 ()
32
Get Input from User
G\Data\Java\InputAppgtjava 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\InputAppgt
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
Write a Comment
User Comments (0)
About PowerShow.com