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 ...@@ -6,7 +6,6 @@ title: Q&A
Any questions about: Any questions about:
- Seventh Assignment Sheet
- Eighth Assignment Sheet - Eighth Assignment Sheet
- Topics from the lectures - Topics from the lectures
- Organisation - Organisation
......
--- ---
title: Agenda title: Agenda
layout: center
--- ---
# Agenda # Recaps & Discussion
- Presentation Discuss the following topics and explain those concepts in your own words to your teammates:
- Java <br/>
---
title: Java I
---
# Java JDK, JRE and JVM
Know the difference between JDK, JRE and JVM.
### What is JVM?
JVM (Java Virtual Machine) is an abstract machine that enables your computer to run a Java program. - What is IPC?
- What is RPC?
<div class="container flex justify-center mt-20"> - What are the differences between RPC and IPC?
<img src="/images/how-java-program-runs.webp" class="block w-lg"/> - What roles do protocols play in IPC/RPC?
</div> - 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"> It is a:
<img src="/images/jdk.webp" class="block w-sm"/>
</div>
--- - Text-based protocol
title: Java III - 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"> ::right::
<img src="/images/jre.webp" class="block w-sm"/>
</div>
--- <div class="container flex justify-center">
title: Java IV <img src="/images/http-header.png" class="block w-md"/>
---
### 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> </div>
--- ---
title: Java Dev Environment Setup title: HTTP(s) II
layout: center
--- ---
# Java Dev Environment Setup ### A typical HTTP request
<br/> <br/>
- Using an IDE is recommended: [IntelliJ IDEA](https://www.jetbrains.com/idea/download/), [Eclipse](https://www.eclipse.org/downloads/) ```http
- 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) GET / HTTP/1.1
- Use [Gradle](https://gradle.org/) for building and running your project, or use the IDE's built-in tools Host: www.example.com
- Use [Package Search](https://package-search.jetbrains.com/) to find your java libraries 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
title: Gradle I Connection: keep-alive
--- ```
# 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
--- ---
title: Gradle II title: HTTP(s) III
--- ---
## Write a Task in Gradle Build Script ### A typical HTTP response
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`
// Set the main class to be executed <br/>
mainClass.set("<main-class>")
// Set classpath dependencies if needed
classpath = sourceSets.main.get().runtimeClasspath
// Set JVM arguments if needed
// jvmArgs = listOf("-Xmx512m")
// Set program arguments if needed ```http
// args = listOf("arg1", "arg2") 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 **HTTP = HTTP + TLS/SSL**
- Adapt the java files in `exercises/client-server` to the project
- Write a task in the Gradle build script to run the server
## Exercises II <div class="container flex justify-center">
<img src="/images/https-detailed.webp" class="block w-md"/>
<br/> </div>
- Using threads to handle multiple clients in the server
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment