diff --git a/java/.gitignore b/java/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..7ad426ff7cf6795c2f2aa44a8e198286af73470f --- /dev/null +++ b/java/.gitignore @@ -0,0 +1,2 @@ +# Ignore the output directory +out/ \ No newline at end of file diff --git a/java/.vscode/extensions.json b/java/.vscode/extensions.json new file mode 100644 index 0000000000000000000000000000000000000000..8c2f730cc1625315a6db2c72ef43dff1a3e37db7 --- /dev/null +++ b/java/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "vscjava.vscode-java-pack", // Extension pack for java (language server, linter, formatter...) + "vscjava.vscode-gradle" // Gradle support (if you intend to work on gradle projects, like Minecraft mods) + ] +} diff --git a/java/.vscode/settings.json b/java/.vscode/settings.json new file mode 100644 index 0000000000000000000000000000000000000000..49b2e494b91129cfc771b19c0393a409d5101499 --- /dev/null +++ b/java/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + // Generic settings : + "editor.formatOnSave": true, // Format files on save + "formatFiles.runOrganizeImports": true, // Sort imports when formatting + "editor.codeActionsOnSave": { + // Organize imports on save + "source.organizeImports": true + }, + + // Java + "[java]": { + "editor.defaultFormatter": "redhat.java" + } +} diff --git a/java/Makefile b/java/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..1e6005582d9c456bf6a1070cc64330eb21bd4b2c --- /dev/null +++ b/java/Makefile @@ -0,0 +1,30 @@ + +# Output and source directories +SOURCE_DIR = src +OUTPUT_DIR = out + +# Main source and class files +SRC_FILE = Main.java +CLASS_FILE = Main.class + +# Java compiler and interpreter paths +JAVAC = javac +JAVA = java + +.PHONY: all compile run clean + +# "make" will compile and run the program +all: compile run + +# "make compile" will compile the program +compile: + $(JAVAC) -sourcepath $(SOURCE_DIR) -d $(OUTPUT_DIR) $(SOURCE_DIR)/$(SRC_FILE) + +# "make run" will clear the terminal and run the program +run: + clear + $(JAVA) -classpath $(OUTPUT_DIR) $(basename $(SRC_FILE)) + +# "make clean" will remove the output directory's contents +clean: + rm -rf $(OUTPUT_DIR)/* \ No newline at end of file diff --git a/java/README.md b/java/README.md new file mode 100644 index 0000000000000000000000000000000000000000..68146f6758d9bb4a457e9e92fd65ccfa8f7349a1 --- /dev/null +++ b/java/README.md @@ -0,0 +1,2 @@ +TODO: quel output pour java + commandes avec vscode +TODO: pour Linux VSCode avec le makefile, sinon faire à la main diff --git a/java/src/Lib.java b/java/src/Lib.java new file mode 100644 index 0000000000000000000000000000000000000000..2dc3fefb860339c2f6bc4335d716c207b4915161 --- /dev/null +++ b/java/src/Lib.java @@ -0,0 +1,7 @@ +/** Dependency functions */ +public class Lib { + /** Print a message to stdout */ + public static void sayMessage(String message) { + System.out.println(message); + } +} diff --git a/java/src/Main.java b/java/src/Main.java new file mode 100644 index 0000000000000000000000000000000000000000..bef0508df63526b5e72ad051bc6f88fcf0bb0623 --- /dev/null +++ b/java/src/Main.java @@ -0,0 +1,9 @@ +public class Main { + public static void main(String[] args) { + System.out.println("Hello, World!"); + + String message = "This is a message"; + + Lib.sayMessage(message); + } +} \ No newline at end of file