Skip to content
Snippets Groups Projects
Commit d4fd55a3 authored by Chao Zhan's avatar Chao Zhan
Browse files

update slides

parent 9502f8d4
No related branches found
No related tags found
No related merge requests found
slides/images/how-java-program-runs.webp

6.2 KiB

slides/images/http-header.png

35.7 KiB

slides/images/https-detailed.webp

73.5 KiB

slides/images/jdk-jre-jvm.webp

5.24 KiB

slides/images/jdk.webp

2.71 KiB

slides/images/jre.webp

2.34 KiB

......@@ -6,7 +6,6 @@ title: Q&A
Any questions about:
- Seventh Assignment Sheet
- Eighth Assignment Sheet
- Topics from the lectures
- Organisation
......
---
title: Agenda
layout: center
---
# Agenda
# Recaps & Discussion
- Presentation
- Java
---
title: Java I
---
# Java JDK, JRE and JVM
Know the difference between JDK, JRE and JVM.
### What is JVM?
Discuss the following topics and explain those concepts in your own words to your teammates:
<br/>
JVM (Java Virtual Machine) is an abstract machine that enables your computer to run a Java program.
<div class="container flex justify-center mt-20">
<img src="/images/how-java-program-runs.webp" class="block w-lg"/>
</div>
- What is IPC?
- What is RPC?
- What are the differences between RPC and IPC?
- What roles do protocols play in IPC/RPC?
- What are common protocols used in IPC/RPC?
- What are the external data representations used in IPC/RPC?
- What are marshalling and unmarshalling?
---
title: Java II
title: HTTP(s) I
layout: two-cols
---
### What is JDK?
# HTTP
JDK (Java Development Kit) is a software development kit required to develop applications in Java, including JRE, the compiler, interpreter, etc.
**HTTP** stands for **Hypertext Transfer Protocol**.
It is the protocol that enables communication between different systems, transferring information and data over a network.
<div class="container flex justify-center mt-20">
<img src="/images/jdk.webp" class="block w-sm"/>
</div>
It is a:
---
title: Java III
---
- Text-based protocol
- Stateless protocol
- Application layer protocol
### What is JRE?
It is used for:
JRE (Java Runtime Environment) is a software package that provides Java class libraries, Java Virtual Machine (JVM), and other components that are required to run Java applications.
- Client-server model
- Request-response model
- Distributed, collaborative, hypermedia information system
<div class="container flex justify-center mt-20">
<img src="/images/jre.webp" class="block w-sm"/>
</div>
::right::
---
title: Java IV
---
### Relationship between JVM, JRE, and JDK
<div class="container flex justify-center mt-20">
<img src="/images/jdk-jre-jvm.webp" class="block w-sm"/>
<div class="container flex justify-center">
<img src="/images/http-header.png" class="block w-md"/>
</div>
---
title: Java Dev Environment Setup
layout: center
title: HTTP(s) II
---
# Java Dev Environment Setup
### A typical HTTP request
<br/>
- Using an IDE is recommended: [IntelliJ IDEA](https://www.jetbrains.com/idea/download/), [Eclipse](https://www.eclipse.org/downloads/)
- Install JDK: [Oracle JDK 17](https://docs.oracle.com/en/java/javase/17/install/overview-jdk-installation.html#GUID-8677A77F-231A-40F7-98B9-1FD0B48C346A) (same version on Andorra)
- Use [Gradle](https://gradle.org/) for building and running your project, or use the IDE's built-in tools
- Use [Package Search](https://package-search.jetbrains.com/) to find your java libraries
---
title: Gradle I
---
# Gradle
- Gradle is an open-source build automation tool focused on flexibility and performance.
- Gradle build scripts are written using a **Groovy** or **Kotlin** DSL.
- Check out the [Installation Guide](https://docs.gradle.org/current/userguide/installation.html)
- `build.gradle/build.gradle.kts` is the main configuration file for a Gradle project
- `gradlew` is the Gradle wrapper script, which is used to execute Gradle tasks for Linux or MacOS
- `gradlew.bat` is the Gradle wrapper script for Windows
```http
GET / HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: en-GB,en;q=0.5
Accept-Encoding: gzip, deflate, br
Connection: keep-alive
```
---
title: Gradle II
title: HTTP(s) III
---
## Write a Task in Gradle Build Script
Write a task in gradle build script to run java program.
```kotlin
tasks.register<JavaExec>("<task-name>") {
// if your program needs input from stdin
standardInput = System.`in`
### A typical HTTP response
// Set the main class to be executed
mainClass.set("<main-class>")
// Set classpath dependencies if needed
classpath = sourceSets.main.get().runtimeClasspath
// Set JVM arguments if needed
// jvmArgs = listOf("-Xmx512m")
<br/>
// Set program arguments if needed
// args = listOf("arg1", "arg2")
}
```http
HTTP/1.1 200 OK
Date: Mon, 23 May 2005 22:38:34 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 155
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux)
ETag: "3f80f-1b6-3e1cb03b"
Accept-Ranges: bytes
Connection: close
<html>
<head>
<title>An Example Page</title>
</head>
<body>
<p>Hello World, this is a very simple HTML document.</p>
</body>
</html>
```
See live demo in the tutorial.
---
title: Gradle III
title: HTTP(s) IV
---
## Exercises I
### HTTPS
<br/>
**Hypertext Transfer Protocol Secure (HTTPS)** is an extension of the HTTP protocol.
- Create a new Gradle project
- Adapt the java files in `exercises/client-server` to the project
- Write a task in the Gradle build script to run the server
**HTTP = HTTP + TLS/SSL**
## Exercises II
<br/>
- Using threads to handle multiple clients in the server
<div class="container flex justify-center">
<img src="/images/https-detailed.webp" class="block w-md"/>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment