* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Java - Introduction
Class (computer programming) wikipedia , lookup
Go (programming language) wikipedia , lookup
Library (computing) wikipedia , lookup
Object-oriented programming wikipedia , lookup
C Sharp syntax wikipedia , lookup
Java syntax wikipedia , lookup
Name mangling wikipedia , lookup
Interpreter (computing) wikipedia , lookup
Scala (programming language) wikipedia , lookup
Java (programming language) wikipedia , lookup
Java - Introduction Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Introduction Origin A part of a development of an advanced software for consumer electronics Small, reliable, portable, distributed, real-time embedded systems Problems Compiler technology Several other problems Solution Changing language Java 2 (2012-1) Java Features (1) 3 Simple Object-oriented Distributed Interpreted Robust Secure Architecture neutral Portable high-performance Multithreaded Dynamic (2012-1) Java Features (2) Simple Omitted features from C++ Operator overloading Multiple inheritance Extensive automatic coercions Added features Auto garbage collection: easy programming, reduction of bugs 4 (2012-1) Java Features (3) Being small Construction of software the can run stand-alone in small machines Size of basic interpreter and class support: 40K bytes + basic standard libraries and thread support: additional 175K Object-Oriented Clean definition of interfaces Provide reusable “software ICs” Design for data (object) and interface to it 5 (2012-1) Java Features (4) Distributed Extensive library of routines for TCP/IP protocols: HTTP, FTP, … Robust Java is intended to write reliable programs Early checking for possible problems dynamic (runtime) checking eliminate situations that are error prone Strongly typed language: compile time checking Pointer model: eliminates the possibility of overwriting memory and corrupting data 6 (2012-1) Java Features (5) Secure Java is intended to be used in networked/distributed environments Authentication techniques based on public-key encryption Architecture Neutral Java is designed to support applications on networks Compiler generates an architecture neutral object file format Bytecode instructions Easy to interpret on any machine Easily translated into native machine code on the fly 7 (2012-1) Java Features (6) Portable No implementation dependent aspects of the specifications “int”: a signed two’s complement 32 bit integer “float”: 32-bit IEEE 754 floating point number Libraries of the system define portable interfaces Abstract Window class Implementations of it for Unix,Windows, and the Macintosh 8 (2012-1) Java Features (7) Interpreted Java interpreter: execute Java bytecode More compile-time information is available at runtime Linker’s type checking RPC protocol derivation Easy to debugging 9 (2012-1) Java Features (8) High performance Bytecode can be translated on the fly into machine code Automatic register allocation Complier does some optimization Reasonably good code The performance of bytecodes converted to machine code is almost indistinguishable from native C or C++ 10 (2012-1) Java Features (9) Multithreaded Threads: lightweight processes or execution contexts Doing many things at the same time Sophisticated set of synchronization primitives based on the monitor and condition variable paradigm Better interactive responsiveness and real-time behavior 11 (2012-1) Java Summary Java language provides a powerful addition to the tools that programmers have at their disposal Java makes programming easier: OO, automatic garbage collection Java applications are ideal for a diverse environment like Internet 12 (2012-1) Java Java’s Running Environment Java bytecode Machine code instruction for Java Virtual Machine “write once, run anywhere” philosophy Java Platform JavaVirtual Machine (JavaVM) Java Application Programming Interface (Java API) package 13 (2012-1) Java 14 (2012-1) Java 15 (2012-1) Java Java program Creation Process Application Create a source file: HelloWorld.java Compile the source file: javac HelloWorld.java Run the program: java HelloWorld Applet Create a source file: HelloWorld.java Create a html file: HelloWorld.html Compile the source file: javac HelloWorld.java Run the program: appletviewer HelloWorld.html 16 (2012-1) Java Getting Started (1) Class: blueprint Object Members Fields: state Methods: behavior, collections of statements 17 (2012-1) Java Getting Started (2) HelloWorld program main: method of class, public, static, void static: belongs to class, not associated with a particular instnace Signature: name of method + parameter list Method declaration: signature + body Method invocation: object reference 18 (2012-1) Java class HelloWorld { public static void main(String[] args) { System.out.println(“Hello, world”); } } 19 (2012-1) Java Getting Started (3) Compile javac HellowWorld.java javac is Java compiler Run java HelloWorld java is the Java bytecode interpreter 20 (2012-1) Java Java Compile and Runtime Environment Java source code bytecodes Bytecodes: instructions for JVM Applets Store byte code files on an HTTP server <applet code=filename> When an user runs applets Bytecodes are loaded into memory and verified for security 21 22