From 32ba6d3cf2e6779b6c1f824341c562d9ae8740b3 Mon Sep 17 00:00:00 2001 From: Thibaut de Saivre <thibaut.de-saivre@polytechnique.edu> Date: Tue, 17 Oct 2023 15:37:48 +0200 Subject: [PATCH] finish java project config --- java/README.md | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/java/README.md b/java/README.md index fdc1035..252841f 100644 --- a/java/README.md +++ b/java/README.md @@ -7,18 +7,38 @@ Where install jdk, path to java and javac In order to be able to compile and run Java code, you need to install a JDK (Java Development Kit) on your computer. A JDK contains a java compiler (`javac`) and a java interpreter (`java` - JRE = Java Runtime Environment). -You can find JDKs at https://openjdk.org/install/ (latest JDK at https://jdk.java.net/). -If you are using Linux or MacOS, you should install a JDK using your package manager (apt, brew, ...). +Recommended JDK for windows : https://adoptium.net/temurin/releases/?os=windows&arch=x64&package=jdk. + +You can find other JDKs at https://openjdk.org/install/ (latest JDK at https://jdk.java.net/). + +**If you are using Linux or MacOS, you should install a JDK using your package manager** (apt, brew, ...). ### Commands -How this project is configured + the commands +In this template project, we have chosen the following points : + +- use `src/` as the source directory (containing all java files) +- use `out/` as the output directory (containing all compiled `.class` files) +- use `src/Main.java` as the main file of the java program -TODO : for Windows in particular, because there is no default Makefile support +From this configuration, you can use the following commands in the `java/` folder in order to compile and run your program. + +```bash +javac -sourcepath src -d out src/Main.java # Compile +java -classpath out Main # Run +``` ### Linux / MacOS - Makefile -TODO : how to use the makefile +For OS that support the `make` command, the [`Makefile`](./Makefile) defines some commands to compile, run and clean your project. +You can use it to personalize the project structure. + +```bash +make compile # Compile the project +make run # Run the project +make clean # Clear the output directory +make # Compile, clear terminal and run +``` ## VSCode Project Settings -- GitLab