Add .gitea/workflows/java-test.yml
Some checks failed
CI Demo / build (push) Successful in 3s
Java Test / java-hello (push) Has been cancelled
Swift Test / swift-hello (push) Has been cancelled

This commit is contained in:
2025-08-07 18:28:43 +00:00
parent 67493f92f6
commit fd17fe6470

View File

@@ -0,0 +1,32 @@
name: Java Test
on: [push]
jobs:
java-hello:
runs-on: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Java 17 if missing
run: |
if ! command -v java >/dev/null; then
sudo apt-get update
sudo apt-get install -y openjdk-17-jdk
fi
# Installs OpenJDK 17 from Ubuntus repos if java isnt on the PATH :contentReference[oaicite:0]{index=0}
- name: Verify Java installation
run: java --version
- name: Compile & run HelloWorld
run: |
cat > HelloWorld.java << 'EOF'
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, Java 17!");
}
}
EOF
javac HelloWorld.java
java HelloWorld