//TestJavaHome returns a string if the javahome is valid, an empty if not func TestJavaHome(home string) string { javaExecutable := "java" if home == "" { return javaExecutable } if helper.IsRunningOnWindows() { javaExecutable = filepath.Join(home, "bin", "java.exe") } else if helper.IsRunningOnLinux() { javaExecutable = filepath.Join(home, "bin", "java") } else { panic("Can not detect operatingsystem. Supported are: Windows, Linux") } if helper.DoesFileExist(home) { return javaExecutable } return "" }
//RunHandler runs external program with no parameters func RunHandler(executable string) { fmt.Printf("Calling Handler executable: %s\n", executable) var returnCode int var err error if helper.IsRunningOnWindows() { returnCode, err = Execute("cmd", "/c", executable) } else if helper.IsRunningOnLinux() { returnCode, err = Execute("sh", "-c", executable) } else { panic("Unkown OS: " + runtime.GOOS) } if err != nil { fmt.Printf("Error while calling: %s\n", executable) } fmt.Printf("Handler [%s] finished with returncode: %d\n", executable, returnCode) if returnCode != 0 { os.Exit(returnCode) } }