# "Hello Java world!"
- Objective: write a Java program to print `Hello Java world!` in a terminal
- Prerequisites: a terminal (`GitBash` for Windows users), a simple text editor and a lot of curiosity
## Prepare the Java environment
- Check your computer whether or not you already have a JDK, check the version, you can have as many version of JDK you need on your machine
- If necessary, download latest [JDK 11](https://adoptium.net/temurin/releases/?version=11) from Open Source Adoptium implementation (not Oracle)
- Choose a local installation directory and uncompress the archive
- Open a terminal and go to the `<PATH_TO_JDK>/bin` subfolder, type `./java --version`, the command should output something like this:
```console
openjdk 11.0.14.1 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)
```
- Create a project folder for the exercise
- Preparation is done, keep the terminal open!
## Let's code and execute the famous "Hello world!"
- Within the project folder, create a text file and name it `HelloWorld.java` (Java is [camelCase](https://fr.wikipedia.org/wiki/Camel_case) sensitive!)
- Edit the file and type in following code:
```java
public class HelloWorld {
public static void main(String[] args) {
System.out.print("Hello Java world!");
}
}
```
- Save the file and go back to the terminal (`<PATH_TO_JDK>/bin`)
- Ask the compiler to compile the `HelloWorld.java` source code file with this command: `./javac "<PATH_TO_PROJECT_FOLDER>\HelloWorld.java"` (quotation marks are required if you have whitespaces in the path, because whitespace is an argument separator)
- Result should be a new `HelloWorld.class` file in the same folder as `HelloWorld.java` (project folder)
- Lets run our HelloWorld program thanks to the command: `./java -cp "<PATH_TO_PROJECT_FOLDER>" HelloWorld`
- Result should be the following output in the terminal: `Hello Java world!` :)
- Learn and understand what the `main` method is in a Java program
- Fun: type in following command from the `bin` directory: `./javap -c "<PATH_TO_PROJECT_FOLDER>\HelloWorld.class"`, learn, understand what the `javap` command does
## Challenge
- Change the code to output `Hello Java world! My name is xxx` where `xxx` is your name, exemple of output in the console: `Hello Java world! My name is Frank`
- Tip: you can pass arguments to a Java program from the command line, this argument could be your name...
## Going further
- Environment variable: learn what an environement variable is. Try to add or update (if you already have the JDK in the path) the path to your JDK 11 in your OS environement variables. To verify if the setting is correct, you should be able to run the hello world program from any directory, no need to `cd` to the JDK `bin` directory anymore, just like you can with the `git` command for example (the Git program is in the path of your environment variables)
- Learn about Java keywords, the ones you have in the hello world program: `public`, `class`, `static`, `void`
- Learn about the Java classes from the JDK, the ones you have in the hello world program: `System`, `String` (pay attention to different ways to represent a string in Java
- Learn about Java arrays, different ways to declare syntactically arrays in Java and assign values