From 582eb15d3f7abb5a5bea6d743ad6bf0b103892d7 Mon Sep 17 00:00:00 2001 From: eskopp Date: Sat, 5 Oct 2024 23:42:33 +0200 Subject: [PATCH] test java --- javacrypt/TestJava.java | 8 ++++++++ makefile | 23 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 javacrypt/TestJava.java diff --git a/javacrypt/TestJava.java b/javacrypt/TestJava.java new file mode 100644 index 0000000..016a9bd --- /dev/null +++ b/javacrypt/TestJava.java @@ -0,0 +1,8 @@ +package javacrypt; + +// Test Class +public class TestJava { + public static void main(String[] args) { + System.out.println("Java compilation and execution successful!"); + } +} diff --git a/makefile b/makefile index e84c74e..23344f2 100644 --- a/makefile +++ b/makefile @@ -1,4 +1,4 @@ -.PHONY: all clean permissions +.PHONY: all clean test permissions clean_test # Define the target executable TARGET = JavaCrypt.jar @@ -10,7 +10,7 @@ SRC_DIR = javacrypt SRC_FILES = $(wildcard $(SRC_DIR)/*.java) # Define the compiler and flags -JAVAC = /usr/bin/javac +JAVAC = javac JAR = jar JAVAC_FLAGS = -Xlint:unchecked @@ -34,3 +34,22 @@ clean: permissions: @echo "Setting execution permissions for the JAR archive..." @chmod +x $(TARGET) + +# Test rule to compile and run a simple Java file +test: $(SRC_DIR)/TestJava.class + @echo "Compiling TestJava.java..." + @$(JAVAC) $(SRC_DIR)/TestJava.java + @echo "Running Java test..." + @java javacrypt.TestJava + @$(MAKE) clean_test + +# Rule to compile the test Java file +$(SRC_DIR)/TestJava.class: $(SRC_DIR)/TestJava.java + @echo "Compiling TestJava.java..." + @$(JAVAC) $(SRC_DIR)/TestJava.java + +# Rule to clean up only the TestJava class files after test +clean_test: + @echo "Cleaning up test class files..." + @rm -f $(SRC_DIR)/TestJava.class + @echo "Test cleanup done!"