Presentation is loading. Please wait.

Presentation is loading. Please wait.

1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project.

Similar presentations


Presentation on theme: "1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project."— Presentation transcript:

1 1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project in danger of being cancelled –Internet exploded in 1993, saved project Used Java to create web pages with dynamic content –Java formally announced in 1995 –Now used to create web pages with interactive content, enhance web servers, applications for consumer devices (pagers, cell phones)...

2 1.9 Java Class Libraries Java programs –Consist of pieces called classes –Classes contain methods, which perform tasks Class libraries –Also known as Java API (Applications Programming Interface) –Rich collection of predefined classes, which you can use Two parts to learning Java –Learning the language itself, so you can create your own classes –Learning how to use the existing classes in the libraries

3 1.10Other High-Level Languages A few other high-level languages have achieved broad acceptance –FORTRAN (FORmula TRANslator) Scientific and engineering applications –COBOL (COmmon Business Oriented Language) Used to manipulate large amounts of data –Pascal Intended for academic use –BASIC Developed in 1965 as a simple language to help novices

4 1.11Structured Programming Structured programming –Disciplined approach to writing programs –Clear, easy to test and debug, and easy to modify –Pascal designed to teach structured programming in universities Not used in industrial or commercial applications Multitasking –Specifying that many activities run in parallel –C and C++ only allow one activity to be performed at a time –Java allows multithreading, where activities can occur in parallel

5 1.12The Internet and the World Wide Web The Internet –Developed 30 years ago, funded by the Department of Defense –Originally designed to link universities, now accessible by hundreds of millions of computers World Wide Web –Allows users to view multimedia-based documents –Internet has exploded Mixes computing and communication Changes the way business is done Information instantly accessible We cover Java applications that use the Internet

6 1.13Basics of a Typical Java Environment Java Systems –Consist of environment, language, Java Applications Programming Interface (API), Class libraries Java programs have five phases –Edit Use an editor to type Java program vi or emacs, notepad, Jbuilder, Visual J++.java extension –Compile Translates program into bytecodes, understood by Java interpreter javac command: javac myProgram.java Creates.class file, containing bytecodes (myProgram.class)

7 1.13 Basics of a Typical Java Environment Java programs have five phases (continued) –Loading Class loader transfers.class file into memory –Applications - run on user's machine –Applets - loaded into Web browser, temporary Classes loaded and executed by interpreter with java command java Welcome HTML documents can refer to Java Applets, which are loaded into web browsers. To load, appletviewer Welcome.html –appletviewer is a minimal browser, can only interpret applets

8 1.13 Basics of a Typical Java Environment Java programs have five phases (continued) –Verify Bytecode verifier makes sure bytecodes are valid and do not violate security Java must be secure - Java programs transferred over networks, possible to damage files (viruses) –Execute Computer (controlled by CPU) interprets program one bytecode at a time Performs actions specified in program –Program may not work on first try Make changes in edit phase and repeat

9 Program is created in the editor and stored on disk. Compiler creates bytecodes and stores them on disk. Class loader puts bytecodes in memory. Bytecode verifier confirms that all bytecodes are valid and do not violate Java’s security restrictions. Interpreter reads bytecodes and translates them into a language that the computer can understand, possibly storing data values as the program executes. Phase 1 Phase 2 Phase 3 Phase 4 Phase 5 Disk Editor Compiler Class Loader Disk Primary Memory............ Primary Memory............ Primary Memory............ Bytecode Verifier Interpreter

10 1.14General Notes about Java and This Book Java –Powerful language –Programming notes Clarity - Keep it Simple Portability - Java very portable, but it is an elusive goal –Some details of Java not covered http://java.sun.com for documentation –Performance Interpreted programs run slower than compiled ones –Compiling has delayed execution, interpreting executes immediately Can compile Java programs into machine code –Runs faster, comparable to C / C++

11 1.14 General Notes about Java and This Book Just-in-time compiler –Midway between compiling and interpreting As interpreter runs, compiles code and executes it Not as efficient as full compilers –Being developed for Java –Integrated Development Environment (IDE) Tools to support software development Several Java IDE's are as powerful as C / C++ IDE's

12 Hello World

13 Comments The Java language supports three kinds of comments: /* text */ The compiler ignores everything from /* to */. /** documentation */ This indicates a documentation comment (doc comment, for short). The compiler ignores this kind of comment, just like it ignores comments that use /* and */. The JDK javadoc tool uses doc comments when preparing automatically generated documentation. For more information on javadoc, see the Java tool documentation. // text The compiler ignores everything from // to the end of the line.

14 Applet

15 HTML A Simple Program Here is the output of my program:


Download ppt "1.8History of Java Java –Based on C and C++ –Originally developed in early 1991 for intelligent consumer electronic devices Market did not develop, project."

Similar presentations


Ads by Google