Transcript Training
Java: A to Z Delivered By: Alexander Day Chaffee, Purple Technology Original Creator of Gamelan (http://java.developer.com/ - EarthWeb) [email protected] Copyright © 1997-8 Alex Chaffee Purple Technology Java Training and Consulting All levels of courses http://www.purpletech.com/ Copyright © 1997-8 Alex Chaffee What is Java? An island Largest island of the equatorial achipelago of Indonesia Famous for beaches and coffee Copyright © 1997-8 Alex Chaffee What is Java? A programming language Developed by Sun Microsystems Open specification Copyright © 1997-8 Alex Chaffee What is Java? An architecture Virtual Machine Copyright © 1997-8 Alex Chaffee What is Java? A platform Libraries / APIs Applications Applets Copyright © 1997-8 Alex Chaffee What is Java? An Operating System (OS) Tailored for NCs and Embedded Systems Not an OS for PCs Copyright © 1997-8 Alex Chaffee What is Java? A really good buzzword Coined by Kim Polese Copyright © 1997-8 Alex Chaffee Why Java? High Productivity Low Cost Run Anywhere N-tier Applications Copyright © 1997-8 Alex Chaffee Where is Java? Server-side programming Enterprise computing Distributed computing Client-side multimedia Copyright © 1997-8 Alex Chaffee Where is Java heading? Clients (Network, Distributed Computing with Nodes) Servers (Web servers, collaboration services) Embedded (TV Set-top, cell phones, smart cards) Copyright © 1997-8 Alex Chaffee Facts and Figures Copyright © 1997-8 Alex Chaffee Number of Java Developers (IDC) Copyright © 1997-8 Alex Chaffee Real-world Java Examples Copyright © 1997-8 Alex Chaffee Andersen Consulting 60,000 employees who travel to client sites VERY heterogeneous computing environments On-line travel system for their in-house needs Privileges according to employee status Andersen Consulting (cont.) "Java is absolutely ready for prime time. It's the most bulletproof language we've used. We don't have to worry about memory leaks. If we had done this in C, we would still be debugging." -Elmer Baldwin, President, via World Network. Copyright © 1997-8 Alex Chaffee CSX railway shipping Find out which train(s) have your freight on map of USA Click on train and see what freight belongs to your company Saving CSX $10M in next year Copyright © 1997-8 Alex Chaffee CSX railway shipping (cont.) CSX, using Java, has halved the time to write code and moved to a zero cost software distribution model. At the same time, CSX has moved to a multi-client environment, improved satisfaction, expanded reach and selfenabled the customer Copyright © 1997-8 Alex Chaffee CSX (cont.) "Java is CSX's enterprise computing solution Java is deployed everywhere and at every level of CSX. And we are working on architecturally purifying CSX development," said Marshall Gibbs, assistant VP of enterprise solutions at CSX Technology in Jacksonville, FL, the IT unit of CSX Corp. "Our ROI on projects where we use Java has increased by 10 percent." Copyright © 1997-8 Alex Chaffee Dun & Bradstreet On-line office supply catalogue for in-house use Privileges according to status at company Copyright © 1997-8 Alex Chaffee Federal Express "Java is our primary targeted application platform for internal apps." says FedEx CIO Dennis Jones. "No internal application work is occurring for the client aside from Java development." Using Symantec Café Copyright © 1997-8 Alex Chaffee Ford Motor Credit Company. "Ford Credit is using Java and the Internet to better serve our customers. Ford Credit is currently using Java to provide customers a convenient way to access account information - 24 hours a day, 7 days a week." -Terry Bone, Ford Motor Credit Company Copyright © 1997-8 Alex Chaffee National Library of Medicine (NIH) Using Java for health and information professionals to access database Users' displays tailored to suit information (instead of line-oriented displays) "The development of Java saved us the cost of developing to platform-specific window environments and greatly speeded up our delivery of a working prototype version of HSTAT (roughly six months from design to delivery)." Copyright © 1997-8 Alex Chaffee First Union Corp. "Java gives us greater selection of what applications we can use. Well over 90% of development is Java based," said Michael Love, vice president of the smart card initiative at First Union Corp in Charlotte, NC. Copyright © 1997-8 Alex Chaffee Java Foundations Copyright © 1997-8 Alex Chaffee What is a computer? CPU Memory Input/output devices What is a programming language? Set of instructions for computer Stored in memory, executed by CPU Grammar Examples Perl C C++ BASIC LISP Lifecycle of a program Source code Compiler Object code Linker Executable code What is a Script? A script is a program, but not all programs are scripts Scripting Languages: Lingo Perl JavaScript TCL Script vs. Program Scripts are… smaller easier learning curve less scalable number more of developers per script is usually one task-specific usually tailored to a specific program or function fewer functions available Script vs. Program Programs are… usually larger more powerful more task-independent more scalable programs more can have dozens of programmers code libraries can produce their own graphical user interface Lifecycle of a script Source code Interpreter Perl Right on the line between scripting and programming language Possible to write large programs in Perl Not Many a good idea libraries available for Perl Not very good GUI support Contains compiler and interpreter Java Code Simple Distributed Robust Secure Portable Multi-Threaded Object Oriented Interpreted Safe Architecture Neutral High Performance Dynamic (GC) Copyright © 1997-8 Alex Chaffee Boy Scout Code trustworthy helpful courteous obedient thrifty clean loyal friendly kind cheerful brave reverent Copyright © 1997-8 Alex Chaffee History Green Project / FirstPerson / Oak Consumer electronics Set-top boxes James Gosling, Patrick Naughton Copyright © 1997-8 Alex Chaffee History LiveOak Arthur (1993) van Hoff WebRunner Patrick (1994) Naughton, Jonathan Payne Java Kim Polese Copyright © 1997-8 Alex Chaffee History Fall 1994: WebRunner written Spring 1995: Java/HotJava announced at SunWorld ‘95 Fall 1995: Java Day New York Birth Spring of Gamelan 1996: First JavaOne (San Francisco) Copyright © 1997-8 Alex Chaffee What is an Operating System? A program that runs other programs Sits between programs and devices Manages scheduling of concurrent programs Provides API to applications Application Program Interface What is a Platform? Combination of OS, API, installed programs, and hardware Sometimes means one of those things, sometimes means many Platform Independent: Why? Write once, run anywhere One code base to develop Upwardly compatible with new technology Writing code that will run on machines that haven't been invented yet Cross-compatible with existing installed base E.g. all the computers on the Web Copyright © 1997-8 Alex Chaffee Cross-Platform Write-Once-Run-Anywhere AIX, HP-UX, MacOS, OS2, Win95, WinNT, Netware, UnixWare, Irix, Solaris, and others Copyright © 1997-8 Alex Chaffee Platform Independent: How? Application Application Application Virtual Machine Windows MacOS Unix Copyright © 1997-8 Alex Chaffee Java Class Lifecycle Source -> Bytecode -> Interpreter Copyright © 1997-8 Alex Chaffee Java Class Lifecycle Java Virtual Machine (JVM) Source File (.java) ClassLoader Bytecode Verifier Compiler (javac) Interpreter Class File (.class) Network or File System = security gateway Just-in-time compiler Security Manager Operating System Security Architecure Has to go through Verifier on one side and Security Manager on the other Sandbox Cryptography / signed applets Copyright © 1997-8 Alex Chaffee Secure Java: Adjustable security: “untrusted” through levels of trust ActiveX: Binary trust: all or nothing Copyright © 1997-8 Alex Chaffee Java vs. ActiveX Java ActiveX File IO yes yes Network IO yes yes Applet Caching yes yes Erase hard disk no yes Upload confidential information no yes Copyright © 1997-8 Alex Chaffee Object-Oriented Encourages more flexible and reliable designs Fosters reuse of code and design Reduces maintenance costs Copyright © 1997-8 Alex Chaffee Automatic Memory Management Greatly improves developer productivity Reduces “memory leakage” problems Copyright © 1997-8 Alex Chaffee Powers of ten Cost of fixing problems Design = $1 Development = $10 Debugging = $100 Deployment = $1000 Brooks, The Mythical Man Month Java helps at early stages Problems are caught early Copyright © 1997-8 Alex Chaffee Distributed Computing Applications reside where they’re needed saving valuable desktop space Accessible from any connected location Native support for distributed app development (java.net, RMI, CORBA, DCOM) Copyright © 1997-8 Alex Chaffee Server-side strength Built-in support for networking makes development easy Copyright © 1997-8 Alex Chaffee 3-tier and n-tier development Flexible implementations separate user interface from business logic and from database storage Copyright © 1997-8 Alex Chaffee Client-side Java Copyright © 1997-8 Alex Chaffee Applications Installed Like locally any other application (Word, Photoshop) Run as a local process Can make network connections freely No security restrictions Still safety restrictions (e.g. can’t write to random memory) Copyright © 1997 Alex Chaffee Applets Live inside a browser Stored as class files on a Web server Are delivered through the internet or intranet On-demand, when needed Run inside a Java-enabled web browser Always downloads the latest version Sometimes cached locally, but not reliably Copyright © 1997 Alex Chaffee Applet Security Security restrictions Are secure Limited or no access to the local machine (“client”) Applets (Diagram) Browser Web Server Here is my face: face.html face.class Copyright © 1997 Alex Chaffee Sockets and Ports (Diagram) Client Socket port 13 Time Service port 80 Web Service Socket Server Copyright © 1997 Alex Chaffee Applet as Input Form Interactive Verify input Can send data to CGI or to custom server More efficient use of client and server resources Copyright © 1997 Alex Chaffee Applet Security Model a/k/a “The Sandbox” Can’t access local files Can’t launch local applications Can only connect to “applet host,” i.e. the host from which the applet itself was downloaded Can’t accept connections, i.e. can’t act as a server Copyright © 1997 Alex Chaffee Applet Tag <APPLET CODE=Animator HEIGHT=100 WIDTH=100> <PARAM NAME=speed VALUE=50> </APPLET> Browser Virtual Machine Every browser has its own VM Starts up either at launch or the first time Java is needed “Starting Java...” Browser compatibility Every version of Java is slightly different Browsers, yuck Navigator 2.x, 3.x, 4.x Internet Explorer 3.x, 4.x HotJava We need... Copyright © 1997-8 Alex Chaffee The Activator Copyright © 1997-8 Alex Chaffee Activator, a/k/a Java Plug-in uses latest JRE to deploy Java on intranets eventually, on Internet Not a perfect solution Copyright © 1997-8 Alex Chaffee Microsoft's Java Copyright © 1997-8 Alex Chaffee Java vs. HTML HTML is a presentation format Was never meant to be used for interactive applications Latency, or turn-around time, is too high Dynamic HTML is really just window dressing Copyright © 1997-8 Alex Chaffee Java vs. HTML Java is a full-fledged application language High-level of interaction with low-latency More powerful and easier to use interfaces Flexible enough to play any part in a solution Copyright © 1997-8 Alex Chaffee Java can do it all Server-side or back-end processing Middleware to transport and translate information Front-end user interface Adapts to client: from PC’s, NC’s to Handheld devices Copyright © 1997-8 Alex Chaffee Marimba Castanet Marimba Castanet delivers applications Changes nature of software No more upgrades! Just automatic updates http://www.marimba.com/ Founded by four original Java team members Copyright © 1997-8 Alex Chaffee Java vs. JavaScript Totally different technologies JavaScript Browser scripting language Integrated with HTML page Similar syntax Java and Multimedia Java and Streaming Streaming - starting to play a sound or video before it has completely downloaded A few streaming players written in Java Flash Shockwave Multimedia FAQ Is Java low-bandwidth friendly? Con: Startup time Need to load class files as well as media files Pro: Complete control over what media you download at what time Class files usually small Is there an authoring environment to help you write Java? A few packages allow you to create animations or ads and output class files There are plenty of IDEs that require you to write code Many IDEs use Java Beans to make programming more visual How does one with no programming knowledge oversee a Java based project? What are some simple uses of Java on a Web site? Playing a sound Displaying an animation better to use GIF89 Interactive better form to use JavaScript Interactive banner ad What's a good price to pay for a Java programmer you aren't sleeping with? $50-$150 / hr Is Java good for developing games? Sure, if you keep the window small MPlayer http://www.mplayer.com/java/games/ Will Java be around 2 years from now? Absolutely Can you show me some kewl stuff done in Java? http://www.tdb.uu.se/~karl/brain.html http://www.mplayer.com/java/games/ http://fragisland.fragzone.se Server-side Java Copyright © 1997-8 Alex Chaffee Servlets Cross-platform server-side scripting Like CGI, only cooler Copyright © 1997-8 Alex Chaffee Java Web Server Server written in Java Runs servlets Cheap Copyright © 1997-8 Alex Chaffee Java Application Server Based on Java Web Server High-performance Enterprise Java Beans Copyright © 1997-8 Alex Chaffee Enterprise Java Beans Framework for enterprise servers Adds transactions, persistence, multithreading to server Deals with tough issues, keeping server-side business objects simple Many EJB servers (IBM, Weblogic, JavaSoft, etc.) Copyright © 1997-8 Alex Chaffee Java Components Copyright © 1997-8 Alex Chaffee Spaghetti Code Business logic mingled with systems code Ported to legacy systems Complex to develop Expensive to maintain Copyright © 1997-8 Alex Chaffee Java Beans Marketable software parts Business applications as reusable components Leverages legacy systems Easy to build/extend Easy to distribute Copyright © 1997-8 Alex Chaffee What is a component? Software “part” Self-contained, independent Plug-and-play, drag-and-drop Interact and interoperate with other components Assemble components to create an application Ready for use by visual programming tools Marketable Copyright (c) 1997 Alex Chaffee Split Development JavaBeans producers Create components for user-interface and business-logic JavaBeans consumers Use JavaScript Applet Embedding for web pages Use JavaStudio and other visual development tools Copyright © 1997-8 Alex Chaffee Commercial User-Interface JavaBeans JScape (www.jscape.com) KL Group (www.klg.com) Lotus Kona project (www.lotus.com) Rogue Wave Dundas Many more: see http://www.javasoft.com/beans/ Copyright © 1997-8 Alex Chaffee Enterprise Java Beans Adds business services to Java Transactions, naming, etc. Simplified development don’t need to worry about threading, locking, transaction issues IBM heavily involved Copyright © 1997-8 Alex Chaffee Java Myths Copyright © 1997-8 Alex Chaffee Myth: Java is Proprietary Truly open standards Developed in collaboration with other partners IBM, Symantec, Intel, Oracle, … Long period of public comment and revision Several "clean-room" implementations underway Kaffe Sun does not compete with application developers Or does it? (Java Application Server, HotSpot) Java is an ISO Publically Available Standard Copyright © 1997-8 Alex Chaffee approved 20 to 2 Myth: Java has poor performance Video Games Island – Quake Rendering Engine (http://fragisland.fragzone.se/) Warp - Karl Hornell is God (http://www.tdb.uu.se/~karl/java/warp.html) Frag Built-in Multi-threading improves performance Copyright © 1997-8 Alex Chaffee Myth: Java has poor performance Interpreter is fine for IO-bound apps (including UI) Very fast with Just-in-time (JIT) compilers Now available on most platforms HotSpot Object-oriented optimization Generational Garbage Collection malloc/free test: JVM 18 sec, MSJVM 8 sec, C++ 6 sec, HotSpot 2 sec. Many other enhancements Copyright © 1997-8 Alex Chaffee Myth: Java has poor performance Compile to native code where possible Compile server-side applications directly to the platform on which they’ll be used SuperCede and Symantec Café/Visual Café support this Note: lose some benefits of Java (notably dynamic linking) Copyright © 1997-8 Alex Chaffee Myth: Java is immature Compiler Bugs Almost none in real-world experience Java Compatibility Test required by all JavaVM licensees Copyright © 1997-8 Alex Chaffee Myth: Java is immature Class Library Bugs AWT in JDK 1.1 much improved JFC takes Java UI to the next level Copyright © 1997-8 Alex Chaffee Myth: Java is immature Java Virtual Machine problems Most are from implementations in browsers They lag behind JDK releases Affects “cross-platform” compatibility 100% Pure Java crusade, run seamlessly across platforms Activator Copyright © 1997-8 Alex Chaffee Myth: Write once, run anywhere Should be, “Write once, debug everywhere, run anywhere” Need a good debugger (like Café) Copyright © 1997-8 Alex Chaffee Java Myths: NCs vs. PCs PC vs NC: reality both will co-exist and overlap in functionality Network and server load issues: reality careful system administration and caching required Don't need to throw everything away and start from scratch Copyright © 1997-8 Alex Chaffee Myth: Java vs. Microsoft Java works great under Microsoft OS IIS has full Java integration for ASPs Copyright © 1997-8 Alex Chaffee Java Libraries and APIs Copyright © 1997-8 Alex Chaffee Java API Strategy Copyright © 1997-8 Alex Chaffee Core Libraries (APIs) UI JFC IO Net JDBC RMI Copyright © 1997-8 Alex Chaffee Extended APIs Electronic Commerce Network Management Security JavaBeans - GUI Components Enterprise Java - Enterprise Wide Backend Database Connectivity Server - Web Server or Distributed Applications JavaMedia - Multimedia Copyright © 1997-8 Alex Chaffee User Interface: AWT Based on native widgets Native look-and-feel Simple components Copyright © 1997-8 Alex Chaffee Swing/JFC Builds on AWT and IFC Pluggable look and feel Rich set of pre-defined components Fully customizable Simplify commercial GUI development Open component market Copyright © 1997-8 Alex Chaffee Swing GUI Copyright © 1997-8 Alex Chaffee AFC / WFC Microsoft's alternative Write once, run on Windows Out as of March 11, 1998 Copyright © 1997-8 Alex Chaffee Standard Extensions Servlets InfoBus Java Help JavaMail Copyright © 1997-8 Alex Chaffee Java and Business JDBC JNDI (Java Naming and Directory Interface) Java Transaction Services Enterprise Java Beans Copyright © 1997-8 Alex Chaffee Distributed Computing Copyright © 1997-8 Alex Chaffee java.net uses TCP/IP works on all Java platforms all open protocols of the Internet HTTP, Source FTP, SMTP, IMAP code: Socket s = new Socket (“www.internet.com”,80); Copyright © 1997-8 Alex Chaffee Other Network Technologies RMI CORBA JDBC Other Java Initiatives/Environments Copyright © 1997-8 Alex Chaffee JavaPC Turn old PCs into NCs Copyright © 1997-8 Alex Chaffee Personal Java Tailored for products such as mobile phones, set top boxes, screenphones, midrange mobile phones Designed to fit in devices with 2 Mb or less Copyright © 1997-8 Alex Chaffee Embedded Java tailored for small memory, high volume products Tailored for products such as industrial controllers, pagers, routers, switches Designed to fit in devices < .5 Mb ROM Doesn't require general purpose applet downloading capabilities Includes the Java VM and core set of APIs Copyright © 1997-8 Alex Chaffee Java Card Use in Smart Cards Java Ring Dallas Semiconductor 32K program RAM, 6K data RAM Serial port interface Contains private key crypto Runs off the “1” bits Auto-zeroing RAM Copyright © 1997-8 Alex Chaffee Other Companies Copyright © 1997-8 Alex Chaffee Netscape First Java licensee Recently announced they're canceling their Java program Java will still work in Netscape with Activator etc. Also working (halfheartedly) on Javagator Copyright © 1997-8 Alex Chaffee Microsoft COM integration IIS AFC / WFC Visual J++ 6.0 SDKJ 3.0 just released in beta Write once, run on Windows Did someone say “lawsuit?” Copyright © 1997-8 Alex Chaffee Symantec First with first out with dev tools, an IDE, a RAD IDE, a JIT, and a database-oriented product Developing JFC core technologies Developing JFC look-and-feels Just-in-time compiler keeps getting better Enhancing debugger support Copyright © 1997-8 Alex Chaffee IBM VisualAge for Java - nice RAD tool San Francisco Enterprise Java Beans Licensing picoJava Copyright © 1997-8 Alex Chaffee Developing Java Copyright © 1997-8 Alex Chaffee Developing Java:IDEs Best ones are on PC Symantec Café Borland JBuilder Microsoft Visual J++ Copyright © 1997-8 Alex Chaffee Developing Java: Java Studio Copyright © 1997-8 Alex Chaffee Conclusion Copyright © 1997-8 Alex Chaffee [APPLAUSE] Copyright © 1997-8 Alex Chaffee [DINNER] Copyright © 1997-8 Alex Chaffee Relevant Web Site Resources Javasoft & Sun: www.javasoft.com & www.sun.com Developer.com: java.developer.com Symantec: www.symantec.com IBM: www.ibm.com/java Borland: www.borland.com SuperCede: www.supercede.com Purple Tech: www.purpletech.com Copyright © 1997-8 Alex Chaffee Credits Purple Technology Java Symantec Corp. Java Training and Consulting Development Tools Advanced Web Technologies Java-only training, mentoring, and consulting company Sun Microsystems JavaOne presentations: Lew Tucker, Alan Baratz, James Gosling Personal Thanks Lew Tucker, Gerry Seidman, Ian McFarland Copyright © 1997-8 Alex Chaffee Appendix: Networking Basics Copyright © 1997 Alex Chaffee Networking Basics TCP/IP vocabulary and concepts WWW vocabulary and concept Copyright © 1997 Alex Chaffee Telnet Application Demo of time service (port 13) Demo of login service (port 23) Demo of HTTP service (port 80) Copyright © 1997 Alex Chaffee A Network Is... node any device on the network host a computer on the network address computer-readable host name for host name human-readable name for host Copyright © 1997 Alex Chaffee A Network Does... datagram (or “packet”) little bundle of information sent from one node to another protocol roles, vocabulary, rules for communication IP the Internet Protocol Copyright © 1997 Alex Chaffee TCP/IP: The Internet Protocol Application Layer (HTTP, FTP, SMTP) Transport Layer (TCP, UDP) Internet Layer (IP) Physical Network Copyright © 1997 Alex Chaffee TCP/UDP/IP IP raw packets the “Internet Layer” TCP data stream reliable, ordered the “Transport Layer” UDP user datagrams (packets) unreliable, unordered the “Transport Layer” Copyright © 1997 Alex Chaffee The Three ‘I’s internet any IP-based network Internet the big, famous, world-wide IP network intranet a corporate LAN-based IP network extranet accessing corporate data across the Internet Copyright © 1997 Alex Chaffee IP Addresses IP Address: identifies a host 4 bytes = 2^32 = 4,294,967,296 DNS: converts host names / domain names into IP#s Copyright © 1997 Alex Chaffee IPv6 aka IP: the Next Generation 16-byte addresses 2^128 = 340,282,366,920,938,460,000,000,000,000, 000,000,000 No Y2K problem: InetAddress Class hides implementation Copyright © 1997 Alex Chaffee Sockets and Ports Port: a meeting place on a host one service per port 1-1023 = well-known services 1024+ = experimental services, temporary Socket: a two-way connection Copyright © 1997 Alex Chaffee Sockets and Ports (Diagram) Client Socket port 13 Time Service port 80 Web Service Socket Server Copyright © 1997 Alex Chaffee Well-Known Ports 20,21: FTP 23: telnet 25: SMTP 43: whois 80: HTTP 119: NNTP 1099: RMI Copyright © 1997 Alex Chaffee The World Wide Web Runs on the Internet Uses HTTP protocol Invented by Tim Berners-Lee (and a cast of thousands) Copyright © 1997 Alex Chaffee URL protocol://host[:port][/path/][file][#anchor] http://www.javasoft.com/sfaq/index.html http://www.javasoft.com/sfaq/ ftp://ftp.stinky.com/pub/java/course.zip Copyright © 1997 Alex Chaffee HTTP port 80 default Client: GET path HTTP/1.0 Header: value blank line Server: HTTP/1.0 OK 200 Header: value blank line data telnet demo again Copyright © 1997 Alex Chaffee HTML Text file “Tags” - markup commands embedded in text e.g. This is <B>bold</B> and this is <I>italics</I> Copyright © 1997 Alex Chaffee