Introduction to Java YinHsong Hsu and YenCheng Chen
- Slides: 27
Introduction to Java Yin-Hsong Hsu and Yen-Cheng Chen 1998
History of Java z. Green project funded by Sun for intelligent consumer electronic devices zannounced at May 23, 1995 zexperiences from CE yso many kinds of machines, portability ysimple yno hard disk => network download ysecurity 2
Java - “Write Once, Run Everywhere & Reuse Everywhere” z Java: An Object-Oriented Programming Language for the Internet. z A Better C++-Like Language yobject-oriented, distributed, interpreted, multi-threaded, secure, no pointers, garbage collection, . . . z Platform-independent y. Java programs are compiled into bytecodes, which can be run on Java Virtual Machine. z Java Applets/Servlets: small Java programs executed in WWW browsers/servers. 3
Java z. Simple z. Object-oriented z. Distributed z. Interpreted z. Robust z. Secure z. Architecture-neutral 4 z. Portable z. High performance z. Multithreaded z. Dynamic
Java Applet vs. Java Application z. Applet y. A Java program that runs inside a Java-enabled Web Browser z. Application y. A stand-alone Java program 6
How Java Program Being Executed z. Application Source Code Compile javac prog. java Byte Code Interpret by a virtual machine Interpretation 7
How Java Program Being Executed z. Applet HTML Source Code compile Browser with Virtual Machine JIT: Just In Time Compiler 8 Byte Code Load Bytecode
Programming Environment z. Sun’s JDK (public) yjavac yjava yjdb z. Symantec Visual Café z. Microsoft Visual J++ z. Borland JBuilder z. IBM Visual. Age z. Sybase Power. J 9
First Java Application - Hello World z. Code : Hello. World. App. java class Hello. World. App { public static void main(String[] args) { System. out. println("Hello World!"); } } zcompile to bytecode “Hello. World. App. class” zexecute the bytecode 10
zjavac Hello. World. App. java y. Compile Hello. World. App. java to Hello. World. App. class zjava Hello. World. App y. Interpret Hellow. World. App. class
The anatomy of a Java application z. Comments in Java Code y. C, C++, and /** … */ zdefining a class zthe main() method ymodifiers: public static and void yarguments to the main method zusing classes and objects yclass variables versus instance variables 12
First Java Applet - Hello World z. Code: Hello. World. java import java. applet. Applet; import java. awt. Graphics; public class Hello. World extends Applet { public void paint(Graphics g) { g. draw. String("Hello world!", 50, 25); } } zcompile to bytecode : Hello. World. class 13
Running an Applet z. HTML file : xx. html <APPLET CODE="Hello. World. class" WIDTH=150 HEIGHT=25> z. The Applet tag < applet code=class width=nn height=nn codebase=dir name=n align=str vspace=nn hspace=nn> <param name=pn 1 value=pv 1> <param name=pn 2 value=pv 2>. . . </applet> 14
The anatomy of a Java applet zimporting classes and packages zdefining an Applet subclass zimplementing Applet methods 15
What Applets Can Do? z Applets can usually make network connections to the host they came from. z Applets running within a Web browser can easily cause HTML documents to be displayed. z Applets can invoke public methods of other applets on the same page. z Applets that are loaded from the local file system (from a directory in the user's CLASSPATH) have none of the restrictions that applets loaded over the network do. 16
What Applets Can’t Do? z An applet cannot load libraries or define native methods. z It cannot ordinarily read or write files on the host that's executing it. z It cannot make network connections except to the host that it came from. z It cannot start any program on the host that's executing it. z It cannot read certain system properties. z Windows that an applet brings up look different than windows that an application brings up. 17
Java Core API z. Included in JDK z. Java classes/packages: y. Data manipulation & processing. y. AWT (Abstract Windowing Toolkit). y. I/O. y. Networking. y. Security. y. JDBC (Java Database Connectivity) y. Java. Beans y. RMI (Remote Method Invocation). y. Object Serialization 18
JDK (Java Development Kit) 19
Java Foundation Classes (JFC, swing) 20
Java Family 21
Java Security 22
23
24
25
26
27
- Chen chen berlin
- Rose hsu jordan
- Rose hsu jordan
- Dr te-shao hsu
- Chun-nan hsu
- Jmenu hsu
- Kompetenzstrukturmodell deutsch grundschule
- Teori francis hsu tentang psikososiogram
- Justine janelle
- Ucsd biomedical informatics
- Shih-chieh hsu
- Vincent hsu md
- Maylon hsu md
- Jtag bootloader
- Import java.util.scanner;
- Import java.util.*
- Import java.awt
- Import.java.util.scanner
- Java
- Java gcd
- Random class java
- Java import java.io.*
- Import java
- Java import java.io.*
- Apa perbedaan antara java swing dengan java awt
- Import java.awt.event.*
- Language
- Rmi vs ejb