Presentation is loading. Please wait.

Presentation is loading. Please wait.

Java™ 2 Platform Getting Started.

Similar presentations


Presentation on theme: "Java™ 2 Platform Getting Started."— Presentation transcript:

1 Java™ 2 Platform Getting Started

2 Background / History Sun Microsystems Inc. 1990, “Green Project”
James Gosling 1990, “Green Project” 1991, Develop the Language for Household Products Java James Gosling, Arthur Van Hoff, Andy Bechtolsheim Coffee Materials in Indonesia Write once, Run everywhere Spread Rapidly through WWW and Internet

3 History of Java Pure Object Oriented Language James Gosling
Earlier named Oak later named java

4 Sun Microsystems Sun ( originally developed Java as a language for television “set top boxes,” which were an instrumental component of the anticipated interactive TV explosion. Instead, the Internet and World Wide Web exploded and Java was quickly drawn into the realm of platform independent computing.

5 Sun’s philosophy “The Network is the Computer”™
“Write Once, Run anywhere”™. These two concepts are built into every aspect of Java and J2EE.

6 A Word About the Java Platform
The Java platform consists of the Java application programming interfaces (APIs) and the Java virtual machine (JVM).

7 The Java platform has two components:
The Java Virtual Machine The Java Application Programming Interface (API) it's the base for the Java platform and is ported onto various hardware-based platforms.

8 The Java platform As a platform-independent environment, the Java platform can be a bit slower than native code. However, advances in compiler and virtual machine technologies are bringing performance close to that of native code without threatening portability.

9 API’s Java APIs are libraries of compiled code that you can use in your programs. They let you add ready-made and customizable functionality to save you programming time. The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages.

10 The Java development environment has two parts: a Java compiler and a Java interpreter.

11 Java programs are run (or interpreted) by another program called the Java VM.
Rather than running directly on the native operating system, the program is interpreted by the Java VM for the native operating system.

12 This means that any computer system with the Java VM installed can run Java programs regardless of the computer system on which the applications were originally developed.

13 For example, A Java program developed on a Personal Computer (PC) with the Windows XP operating system should run equally well without modification on a Sun Ultra workstation with the Solaris operating system, and vice versa.

14 Bytecodes and the Java Virtual Machine
Java Development Environment Java Compiler (Pentium) (PowerPC) (SPARC) Java Interpreter Pentium PowerPC SPARC Code ByteCode (Independent on Platform) %javac Hello.java Hello.class created % java Hello JVM Byte Code Run

15 Java Program Java Application Program Application Applet
Program written in general programming language Applet Program running in Web Browser Environment Can be viewed by appletviewer or Web browser with JVM

16 Java technology is both a programming language and a platform.

17 The Java Programming Language
Simple Architecture neutral Object oriented Portable Distributed High performance Multithreaded Robust Dynamic Secure

18 Java Features (1) Simple Object oriented
fixes some clumsy features of C++ no pointers automatic garbage collection rich pre-defined class library Object oriented focus on the data (objects) and methods manipulating the data all functions are associated with objects almost all datatypes are objects (files, strings, etc.) potentially better code organization and reuse

19 Java Features (2) Interpreted Portable
java compiler generate byte-codes, not native machine code the compiled byte-codes are platform-independent java bytecodes are translated on the fly to machine readable instructions in runtime (Java Virtual Machine) Portable same application runs on all platforms the sizes of the primitive data types are always the same the libraries define portable interfaces

20 Java Features (3) Reliable Secure
extensive compile-time and runtime error checking no pointers but real arrays. Memory corruptions or unauthorized memory accesses are impossible automatic garbage collection tracks objects usage over time Secure usage in networked environments requires more security memory allocation model is a major defense access restrictions are forced (private, public)

21 Java Features (4) Multithreaded Dynamic
multiple concurrent threads of executions can run simultaneously utilizes a sophisticated set of synchronization primitives (based on monitors and condition variables paradigm) to achieve this Dynamic java is designed to adapt to evolving environment libraries can freely add new methods and instance variables without any effect on their clients interfaces promote flexibility and reusability in code by specifying a set of methods an object can perform, but leaves open how these methods should be implemented can check the class type in runtime

22 All source code is first written in plain text files ending with the
All source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the javac compiler. A .class file does not contain code that is native to your processor; it instead contains bytecodes — the machine language of the Java Virtual Machine (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine.

23 The Java Platform A platform is the hardware or software environment in which a program runs. Most popular platforms like Microsoft Windows, Linux, Solaris OS, and Mac OS. Most platforms can be described as a combination of the operating system and underlying hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.

24 What Can Java Technology Do?
Development Tools Application Programming Interface (API) Deployment Technologies User Interface Toolkits Integration Libraries

25 Java Technology Change My Life?
Get started quickly Write less code Write better code Develop programs more quickly Avoid platform dependencies Write once, run anywhere Distribute software more easily

26 Object Oriented ? None of the earlier languages provided OO features
Modeling real life ? No code reuse Priority to functions. Data was ignored

27 Major terms Class Object Data Abstraction Data Encapsulation
Code Reuse

28 Java Programming Language?
• A development environment • An application environment • A deployment environment • Similar in syntax to C++, similar in semantics to SmallTalk • Used for developing both applets and applications

29 Primary Goals of Java • Avoiding the pitfalls of other languages
• Being object-oriented • Enabling users to create streamlined and clear code

30 Primary Goals of the Java
• Improved speed of development • Code portability • Enables users to run more than one thread of activity • Supports dynamically changing programs during runtime • Furnishes better security

31 Primary Goals of the Java
• The Java virtual machine (JVM) • Garbage collection • Code security

32 The Java Virtual Machine
• Provides hardware platform specifications • Reads compiled byte codes that are platform independent • Is implemented as software or hardware • Is implemented in a Java technology development tool or a Web browser

33 The Java Virtual Machine
• Instruction set (central processing unit [CPU]) • Register set • Class file format • Stack • Garbage-collected heap • Memory area

34 The Java Virtual Machine
• Byte codes that maintain proper type discipline from the code. • The majority of type checking is done when the code is compiled. • Every Sun approved implementation of the JVM must be able to run any compliant class file.

35 Garbage Collection • Allocated memory that is no longer needed should be deallocated • In other languages, deallocation is the programmer’s responsibility • The Java programming language provides a system level thread to track memory allocation • Checks for and frees memory no longer needed • Is done automatically • Can vary dramatically across JVM implementations

36 Code Security

37 Java Runtime Environment
• Loads code • Verifies code • Executes code

38 Class Loader • Loads all classes necessary for the execution of a program • Maintains classes of the local file system in separate"namespaces" • Prevents spoofing

39 Bytecode Verifier • The code adheres to the JVM specification
• The code does not violate system integrity • The code causes no operand stack overflows or underflows • The parameter types for all operational code are correct • No illegal data conversions (the conversion of integers to pointers) have occurred

40 A Basic Java Application
HelloWorldApp.java 1 // 2 // Sample HelloWorld application 3 // 4 public class HelloWorldApp{ 5 public static void main (String args[]) { 6 System.out.println("Hello World!"); 7 } 8 }

41 Compiling and Running HelloWorld • Compiling HelloWorld.java
javac HelloWorld.java • Running an application java HelloWorld • Locating common compile and runtime errors

42 Features Security Platform Independence, Write Once Run EverywhereTM
High performance Simplicity


Download ppt "Java™ 2 Platform Getting Started."

Similar presentations


Ads by Google