Lecture 1: Introduction To Java: Dr. Sapna Malik Assistant Professor, CSE Department, MSIT
Lecture 1: Introduction To Java: Dr. Sapna Malik Assistant Professor, CSE Department, MSIT
Lecture 1: Introduction To Java: Dr. Sapna Malik Assistant Professor, CSE Department, MSIT
Sun describes it as
"A simple, object-oriented, distributed, interpreted, robust, secure,
architecture neutral, portable, high-performance, multi-threaded and
dynamic language."
What is Java? (cont)
Object-Oriented
Designed to support Object-Oriented concepts
However, does contain non-Object-Oriented primitive data types
Distributed
Applications are constructed using objects. Objects can be
distributed in multiple locations within a network environment.
Extensive integration with TCP/IP
Interpreted
Java compiles to byte-code (not machine code). Byte code is
interpreted.
Most Java versions after 1.2 include a JIT (Just-In-Time) compiler
which compiles byte code to machine code.
What is Java? (cont)
Robust
Memory management is done automatically
Use of pointers is limited
Secure
All Java code subject to security model.
Architecture-Neutral/Portable
Compiled Java (byte code) will run on any platform which has a
Java Virtual Machine
The Java Virtual Machine is available for almost all platforms...
Even mainframes.
What is Java? (cont)
High-Performance
Originally, Java's performance was poor.
Now, Java's performance rivals C++.
Multi-Threaded
Processes contain multiple threads of execution.
Similar to multi-tasking but all threads share the same memory
space.
Dynamic
Makes heavy use of dynamic memory allocation.
Classes can be dynamically loaded at any time.
Platform Independence. How does Java do it?
Because Java source code is compiled to byte code and the byte
code is interpreted, Java code can be executed anywhere an
interpreter is available.
Windows
Compiler i386 binary
Solaris
Source.cpp SPARC binary
Compiler
Mac
PPC binary
Compiler
The Java Virtual Machine.
i386 VM
Java Java
Source.java SPARC VM
Compiler Bytecode
Source.class
PPC VM
Java VM Responsibilities
You might notice, the full SDK is very large (>46 MB)
If you only wish to run Java programs, you do not need to install
the SDK. Instead, you can install the JRE:
Smaller installer file
Less time to download
No compiler or development tools. Just Java VM and support
libraries for specified platform.
When you view the Java API Documentation, you'll note that the
classes are grouped into logical units called "Packages".
To execute, run the Java VM and include the name of the class
which contains the "main" method as the first command line
parameter.