Introduction
Introduction to Java
- 6h CM
- 12h TP
ludovic.deneuville@ensai.fr- office 161
- class based on those by Ikko Yamane, Benjamin Girault, Romaric Gaudel, Samuel Toubon and Olivier Levitt
Objectives
- Learn the basic syntax of Java
- Understand key OOP concepts
- Learn how to use collections
- Best practices
TP
- 4 x 3h
- Datalab SSPCloud
- Follow instructions precisely
- Don’t use GenAI
Evaluation
- Graded TP
- 2 students max per group
- to be completed at home
- Table-top exam
- duration: 1h30
- a handwritten A4 sheet allowed
Why Java
History / Version
- Created in 1991
- by James Gosling and Mike Sheridan (Sun Microsystems)
- Java 8 (2014) : Lambda, Stream, Optional
- Java 17 (2021)
- Java 21 (2023)
- Java 25 (sept. 2025)
- Facebook story (Sun Microsystems)
- LTS
- 2009 Oracle
- 2017 Java 9 -> Modules
- 2018 Java 11
- Java 17 : Sealed Classes, Refactor JDK
Popular / Mature
- Widely used in all sectors
- Back-end, Mobile, Big Data
- Heavily object-oriented
- Enterprise Applications
- Backend Development (Spring Boot)
- Mobile Development (via Kotlin & Android SDK)
- Big Data & Machine Learning
Portability
- Compiled to bytecode
- Runs on any machine with a JVM
- “Write Once, Run Anywhere”
WORA: desktop, servers, smartphones
Robust / Secure
- Automatic memory management
- Strong Static Typing
- Compile-Time Checks
Static Typing
| Static Typing | Dynamic Typing |
|---|---|
| Type checked at compile time | Type checked at runtime |
| Variable type is declared | Variable type inferred during execution |
| Errors detected earlier | More flexible but errors appear later |
Strong Typing
| Strong Typing | Weak Typing |
|---|---|
| Types are strictly enforced | Implicit conversions are common |
| Few automatic casts | Many implicit conversions |
| Safer and more predictable | More flexible but error-prone |
Compiler
- Transform java code into bytecode
- Detects syntax and type errors
- Optimization
- javac MyClass.java ➡️ create file MyClass.class
JVM
NoteDefinition
The Java Virtual Machine (JVM) is the runtime environment for Java programs. It acts as an interpreter between Java code and the operating system.
The JVM :
- Executes bytecode
- Interacts with OS
- Manages Memory (Garbage Collection)
- java MyClass ➡️ run main method
JVM, JDK, JRE
- JRE: Java Runtime Environment
- JDK: Java Development Kit
| Component | Purpose |
|---|---|
| JVM | Runs Java bytecode |
| JRE | Contains JVM + libraries to run Java apps |
| JDK | Includes JRE + compiler + dev tools |
https://openjdk.org/projects/jdk/
- JRE: java.util, java.io…, $java
- to execute java app
- JDK: $javac, new libraries
- to dev java app
Java Vs Python
| Java | Python | |
|---|---|---|
| Typing | Strongly typed, static | Strongly typed, dynamic |
| Compilation | Compiled into bytecode | Interpreted |
| Performance | Very fast | Slower |
| Syntax | Verbose, requires {} |
Concise, uses indentation |
| Paradigm | Object-oriented | Multi-paradigm |
| Ecosystem | Huge (Spring, Hibernate…) | Large (Django, Flask, Pandas…) |
- Typing:
int x = 10;vsx = 10 - Interpreted: exécution à la volée
- Multi-paradigm (objet, fonctionnel, impératif)
High-level languages
- Human-readable syntax
- Hardware abstraction
- Faster, easier development
- Indirect performance (VM/runtime)
Low-level languages
- Close to hardware
- Fine control over memory/resources
- Maximum performance
- Higher complexity
High/Low-level
| Level | Priority | Typical Uses |
|---|---|---|
| High | Productivity | Web, data, scripting |
| Mid | Balance | Enterprise, backend |
| Low | Control & speed | OS, embedded, real-time |
- High : Python
- Mid : Java
- Low : Rust
- Very Low : C, Assembly
Resources
- https://www.baeldung.com/get-started-with-java-series
- https://www.w3schools.com/java/
- https://www.jmdoudoux.fr/accueil_java.htm