I will develop a small App with Java / JavaFX to shutdown my mac with one click.
Here is my setonaction, windows ist working but not linux or mac os. Maybe someone have a idea. Thanks
button1.setOnAction(new EventHandler<ActionEvent>() {
String commandEx = " ";
@Override
public void handle(ActionEvent event) {
if (os.contains("Windows")) {
commandEx = "shutdown -s -t 10";
} else if (os.contains("Linux")) {
commandEx = "shutdown -h now";
} else if (os.contains("Mac OS X")) {
commandEx = "shutdown -h now";
try {
Runtime.getRuntime().exec(commandEx);
} catch (IOException e) {
e.printStackTrace();
}
}
}
});