Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction
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 (2012-1) Java 2
Features (1) (2012-1) Java 3 Simple Object-oriented Distributed Interpreted Robust Secure Architecture neutral Portable high-performance Multithreaded Dynamic
Features (2) (2012-1) Java 4 Simple Omitted features from C++ Operator overloading Multiple inheritance Extensive automatic coercions Added features Auto garbage collection: easy programming, reduction of bugs
Features (3) (2012-1) Java 5 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
Features (4) (2012-1) Java 6 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
Features (5) (2012-1) Java 7 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
Features (6) (2012-1) Java 8 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
Features (7) (2012-1) Java 9 Interpreted Java interpreter: execute Java bytecode More compile-time information is available at runtime Linker’s type checking RPC protocol derivation Easy to debugging
Features (8) (2012-1) Java 10 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++
Features (9) (2012-1) Java 11 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
Summary (2012-1) Java 12 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
Java’s Running Environment (2012-1) Java 13 Java bytecode Machine code instruction for Java Virtual Machine “write once, run anywhere” philosophy Java Platform Java Virtual Machine (Java VM) Java Application Programming Interface (Java API) package
(2012-1) Java 14
(2012-1) Java 15
Java program Creation Process (2012-1) Java 16 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
Getting Started (1) (2012-1) Java 17 Class: blueprint Object Members Fields: state Methods: behavior, collections of statements
Getting Started (2) (2012-1) Java 18 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
(2012-1) Java 19 class HelloWorld { public static void main(String[] args) { System.out.println(“Hello, world”); }
Getting Started (3) (2012-1) Java 20 Compile javac HellowWorld.java javac is Java compiler Run java HelloWorld java is the Java bytecode interpreter
21 Java Compile and Runtime Environment Java source code bytecodes Bytecodes: instructions for JVM Applets Store byte code files on an HTTP server When an user runs applets Bytecodes are loaded into memory and verified for security
22