Skip to content

Commit

Permalink
test java
Browse files Browse the repository at this point in the history
  • Loading branch information
eskopp committed Oct 5, 2024
1 parent cb24613 commit 582eb15
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
8 changes: 8 additions & 0 deletions javacrypt/TestJava.java
Original file line number Diff line number Diff line change
@@ -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!");
}
}
23 changes: 21 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all clean permissions
.PHONY: all clean test permissions clean_test

# Define the target executable
TARGET = JavaCrypt.jar
Expand All @@ -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

Expand All @@ -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!"

0 comments on commit 582eb15

Please sign in to comment.