package java

import (
	"fmt"
	"os"
	"os/exec"

	"zlh-agent/internal/state"
)

const javaBin = "/opt/zlh/runtimes/java/bin/java"

func Verify(cfg state.Config) error {
	if _, err := os.Stat(javaBin); err != nil {
		return fmt.Errorf("java binary missing at %s", javaBin)
	}

	if err := exec.Command(javaBin, "-version").Run(); err != nil {
		return fmt.Errorf("java runtime not executable: %w", err)
	}

	return nil
}
