Week 1 - Lecture 1
Week 1 - Lecture 1
Lec#1
Expected Background
No cell phones
Sun Microsystems released the first public implementation as Java 1.0 in 1995
Java syntax is similar to C and C++.
The Java technology is:
A programming language
Java can create all kinds of applications
A development environment
A compiler (javac)
An interpreter (java)
A documentation generator (javadoc)
…
Compare it to C++
C++ vs Java
Features Java C++
Data types Supports both primitive scalar types and Supports both primitive scalar
classes types and classes
Object Allocated from heap, accessed through Allocated form heap pr stack
Allocation reference variables ,accessed through reference
(no pointers) variables or pointers
Object de- Implicit (Garbage collection) Explicit (delete operator)
allocation
Binding All binding of messages to methods are Dynamic binding of methods are
dynamic except in the case of methods that optional (using virtual keyword)
cannot be overridden
Grarbage Collection
700 10
Stack Heap
Java Technology
Key Tools for Programming
Editors: Allows user to enter the program. Notepad etc are all editors.
Compilers: Translates the program into target code .
Debuggers: Allows a programmer to run the program to see the execution of the
program and correct any errors.
Profilers: Used to evaluate program’s performance.
Integrated Development Environment (IDE): Combines editor, compiler,
debugger and profiler or a subset into one tool.
Common Java IDEs are Eclipse, Netbeans, BlueJ, and DrJava.
C++ Compilation Process
Java Compilation Process
Java ByteCode
What is ByteCode?
Also known as portable code, is a form of instruction set designed for efficient
execution by software interpreter.
Java Runtime Enviornment
Java Development Kit
Java Runtime Environment
JRE
Java Development Tools
To run Java Applications
e.g. Compiler, Debugger etc
Java Virtual
Java API Machine To develop Java
Classes JVM Applications
Operating System
(Windows, LINUX, ETC)
Hardware
(INTEL,AMD, ETC)
Java As a Programming
Platform
Write the source code and save in files with .java extension
Compile the source code into .class files using the javac compiler
A .class file contains bytecodes (the machine language of the
Java Virtual Machine i.e. Java VM)
Run the application (with an instance of the Java VM) using the
java launcher tool.
Java Program Execution
The java tool loads and starts the VM, and passes the program’s
main classfile (.class) to the machine
The VM uses classloader to load the classfile
The VM’s bytecode verifier checks that the classfile’s bytecode is
valid and does not compromise security
If the bytecode has any problem, the verifier terminates the VM
If all is well with the bytecode, the VM’s interpreter (JIT)
interprets the bytecode one instruction at a time
* Interpretation consists of identifying bytecode instructions , and executing equivalent
native instructions (instructions understood by the physical processor )
javac HelloWorldApp.java
Java HelloWorldApp
HelloWorldApp
(1)Load the JVM
•The Java platform provides an abstraction over the underlying hardware/OS platform
- Portability: the same .class files can run unchanged on a variety of hardware
platforms and operating systems
Java Technology
Java is Popular
Some reports on programming languages popularity
According to
Job advertisements
Book sales
Finding code on the web
…
https://codinginfinite.com/stack-overflow-developers-survey-2019-vs-2018-technology-comparison/
(2019)
Characteristics of the Java PL
class First
{
public static void main(String arg[])
{
System.out.println("Engr. Farrah Aslam welcomes you in AOOP Course");
}
}
Reference Book
Books
Java the complete reference by helbert schildt 7 th edition
Java how to program, by deitel & deital 8 th edition
Additional reference (reccomended)
Head first java 2nd edition
Goal of the course???
Acknowledgments
Preparing this lecture , I have greatly benefitted from the work of
Peyman Dodangeh, Sharif University of Technology
Andy Van Dam (Brown University)
Mark Sheldon (Wellesley College)
Robert Sedgewick and Kevin Wayne (Princeton University)