Introduction to Java 2 Programming : Introduction to Java 2 Programming Lecture 1
Java, Principles of OOP By
Ravi Krishna
Overview : Overview Introducing Java
Key features of the language
Principles of Object Oriented Programming
What is OOP? Why is it important?
Basic principles and advantages.
Some History : Some History Developed and maintained by Sun Microsystems
Originally called Oak
Aimed at producing an operating environment for networked devices and embedded systems
…but has been much more successful
Design objectives for the language
Simple, object-oriented,
Distributed, multi-threaded, and platform neutral
Robust, secure, scaleable
The Virtual Machine : The Virtual Machine Java is both compiled and interpreted
Source code is compiled into Java bytecode
Which is then interpreted by the Java Virtual Machine (JVM)
Therefore bytecode is machine code for the JVM
Java bytecode can run on any JVM, on any platform
…including mobile phones and other hand-held devices
Networking and distribution are core features
In other languages these are additional APIs
Makes Java very good for building networked applications, server side components, etc.
Features of the JVM : Features of the JVM The Garbage Collector
Java manages memory for you, the developer has no control over the allocation of memory (unlike in C/C++).
This is much simpler and more robust (no chance of memory leaks or corruption)
Runs in the background and cleans up memory while application is running
The Just In Time compiler (JIT)
Also known as “Hot Spot”
Continually optimises running code to improve performance
Can approach the speed of C++ even though its interpreted
Features of the JVM : Features of the JVM Security
Java offers very fine control over what an application is allowed to do
E.g. Read/write files, open sockets to remote machines, discover information about the users environment, etc
Used in Java Applets to create a “sandbox”. Stops a rogue applet attacking your machine.
Makes Java very safe, an important feature in distributed systems
Class Loading
Loading of bytecode into the virtual machine for execution
Code can be read from a local disk, over a network, or the Internet
Allows downloading of applications and applets on the fly
…and even ‘mobile code’
Versions of Java : Versions of Java Java Language vs Java Platform
Current version of the language is 1.4.1
Core language plus additional APIs is called the Java 2 platform
Three versions of the Java 2 Platform, targetted at different uses
Java 2 Micro Edition (J2ME)
Very small Java environment for smart cards, pages, phones, and set-top boxes
Subset of the standard Java libraries aimed at limited size and processing power
Java 2 Standard Edition (J2SE)
The basic platform, which this course will cover
Java 2 Enterprise Edition (J2EE)
For business applications, web services, mission-critical systems
Transaction processing, databases, distribution, replication