Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Published byModified over 5 years ago
Presentation on theme: "Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green."— Presentation transcript:
History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green Project (According to Gosling, "the goal was... to build a system that would let us do a large, distributed, heterogeneous network of consumer electronic devices all talking to each other." ) – James Gosling Modified C++ – Named Oak then Java
History… Platform independent ("Write Once, Run Anywhere") Interpreted Language Intermediate Code (Byte Code) Reliable Multiple inheritance and Operator overloading removed No Pointers because of security reasons
History… – Internet exploded in 1993, saved project Reliability Security Platform Independence – Java formally announced in 1995 – Now used to create web pages with interactive content and applications for consumer devices (pagers, cell phones)...
Motivation Motivation Simple Pure Object Oriented Language Allows Multi-threading Automatic Garbage Collection More Robust (Run time exceptions) (Anyone heard of smart cards?)
Disadvantages Speed…Slower than C++ To the rescue: – Just-in-time (JIT) compilation Inability to access platform-specific code To the rescue: – Java Native Interface (JNI) (can also speed up code)
Difference Between C++ and Java Java is C++ minus – Pointers – Destructors – Structs and unions – Templates – Multiple Inheritance – Operator Overloading
Types Of Java Programs Applications: Stand-alone java programs runnable from command prompt Applets: Run from inside a web browser or the appletviewer
Basics of a Typical Java Environment Java Systems – Consist of environment, language, Java Applications Programming Interface (API) – Java programs have five phases 1. Edit.java extension 2. Compile javac command: javac MyProgram.java Creates.class file containing bytecodes
Basics of a Typical Java Environment 3. Loading Class loader transfers.class file into memory Classes loaded and executed by interpreter with java command To load, appletviewer Welcome.html Or java MyFile
Basics of a Typical Java Environment 4. Verify Bytecode verifier makes sure bytecodes are valid and do not violate security 5. Execute Computer interprets program one bytecode at a time Performs actions specified in program
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 machine language for that computer. 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
Java Virtual Machine (JVM) Hypothetical computer that executes a Java program = the interpreter Each computer architecture (Intel x86, Macintosh, etc.) has its own JVM implemented in software Sun Microsystems also has a JVM processor (hardware chip) Web browsers have built-in interpreter
Intro to Some Java Technologies Servlets: Small server-side programs JDBC: Links Java programs to databases RMI: Helps build distributed applications EJBs: Reusable software components