0% found this document useful (0 votes)
12 views

Lecture 1 - Intro To Java

The document provides an introduction to the Java programming language and Java platforms. It discusses Java editions including SE, EE and ME. It also covers Java history, how Java works, the JVM, and key Java concepts like classes, APIs and the development environment.

Uploaded by

Mtoi Tv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Lecture 1 - Intro To Java

The document provides an introduction to the Java programming language and Java platforms. It discusses Java editions including SE, EE and ME. It also covers Java history, how Java works, the JVM, and key Java concepts like classes, APIs and the development environment.

Uploaded by

Mtoi Tv
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

University of Dar es Salaam

CS 234: Object-Oriented
Programming in Java
Introduction to Java

Aron Kondoro
University of Dar es Salaam
The Java Programming Language
• Supports the OO-Language concepts
• Inheritance: to avoid code duplication
• Subtyping: to express classification
• Overriding: to specialize methods
• Dynamic: to adapt reused algorithms
• Platform Independent
• Write Once Run Anywhere
• Robust
University of Dar es Salaam
Why Learn Java?

Versatility

Community Support

High Demand
University of Dar es Salaam
Java: Brief History and Background
University of Dar es Salaam
Java Editions
University of Dar es Salaam
Java Platform, Standard Edition (Java SE)
• Made up of APIs that provide Java features
• Specifies types, objects, classes etc
• This course is based on Java Standard Edition (Java SE)
• JDK: Java Development Kit 18
• https://www.oracle.com/java/technologies/downloads/
University of Dar es Salaam
Java Platform, Enterprise Edition (Java EE)
• Developed to expand the Java SE
• New standards/specifications
• For developing web services to exchange data, manage transactional
interactions etc
• Geared toward developing large-scale, distributed networking
applications and web-based applications.
• JSP, JSF, JPA etc
University of Dar es Salaam
Java Platform, Micro Edition (Java ME)
• Developed to facilitate mobile and embedded device applications
• Not quite as popular as Java SE and Java EE
• Offers an API and a small-footprint virtual machine
• JavaFX
• Provides a modern, hardware-accelerated graphics and media engine
• For building rich online and desktop applications with a simple and powerful
scripting language (JavaFX Script)
• Rich online applications, GUI applications, and Desktop applications
• Replaced Swing as default GUI Library
University of Dar es Salaam
What uses Java?
University of Dar es Salaam
Java Versions
University of Dar es Salaam
Java: A general view
University of Dar es Salaam
Java: Compile Once, Run Anywhere
University of Dar es Salaam
The Java Virtual Machine (JVM)
• An implementation of a physical machine in
software
• It is a specification
• Its implementation is the JRE
• Its functions
• Loads the code
• Executes the code
• Verifies the code
• Provides the runtime environment
University of Dar es Salaam
How Java Works
1. You (programmer) write program source code in Java.
2. Java compiler checks the code and translates it into byte code
3. A Java virtual machine (JVM) runs the byte code.
University of Dar es Salaam
Java Machine Independence
University of Dar es Salaam
Java Class Libraries
• Java programs consist of pieces called classes.
• Classes include methods that perform tasks and return information
when the tasks complete.
• Java class libraries
• Rich collections of existing classes
• Also known as the Java APIs (Application Programming Interfaces)
• Two aspects to learning the Java “world.”
• The Java language itself
• The classes in the extensive Java class libraries
University of Dar es Salaam
Java Development Environment
• We discuss these
phases in the context
of the Java SE
Development Kit 18
(JDK 18) from Oracle.
• Download the most
up-to-date JDK and its
documentation from:
• https://www.oracle.co
m/java/technologies/d
ownloads/
University of Dar es Salaam
How to Write Source Code?
• You can use any editor to write the Java source
code.
• For example, Notepad, TextEdit etc
• You can also use an Integrated Development
Environment (IDE) such as Eclipse, IntelliJ,
NetBeans, or VS Code.
• An IDE makes you much more productive.
• In addition to code editors, they also provide
debuggers, build tools, version control systems,
profilers, testing frameworks etc
University of Dar es Salaam
JVM vs JRE vs JDK
• JVM
• an abstract machine that enables your computer
to run a Java program.
• is ported to different platforms to provide
hardware and operating system independence.
• JRE
• software package that provides Java class libraries,
Java Virtual Machine (JVM), and other components
required to run Java applications.
• JDK
• a software development kit required to develop
applications in Java. When you download JDK, JRE
is also downloaded with it.
University of Dar es Salaam
How to Get Java?
• Install the JDK
• There are many implementations
and versions
• Latest version is Java SE 20
(released March 2023)
• In this course, we are going to use
Java SE 11

https://whichjdk.com/
University of Dar es Salaam
Check your Java Installation
1. Open a command line window (terminal in Mac)
2. Enter java –version and javac –version

• If it prints command not found, then the Java bin directory is not on
your terminal's search path specified by the PATH environment
variable.
University of Dar es Salaam
First Program
University of Dar es Salaam
Program Structure
University of Dar es Salaam
Key Observations (1/2)
University of Dar es Salaam
Key Observations
University of Dar es Salaam
Output
University of Dar es Salaam
Second Program
University of Dar es Salaam
Assignment
• Go to the LMS and do Assignment 0 according to the instructions
University of Dar es Salaam

Questions & Comments


Questions & Comments

You might also like