It might be related to location of the file.
I'd have tried with fixed location first, just to be sure it works.
Also, make sure the file is actually there, inside pth
.
package javafxapplication1;
import java.io.File;
import java.io.IOException;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class JavaFXApplication1 extends Application {
@Override
public void start(Stage primaryStage) {
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
String exeM="/tmp/a.out";
Runtime runtime=Runtime.getRuntime();
String[] cmndM= {"/bin/sh","-c",exeM};
Process pm=null;
File dirM=new File("/tmp");
try {
pm=runtime.exec(cmndM, null, dirM);
}catch (IOException e) {
System.out.println("Error");
}
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
Scene scene = new Scene(root, 300, 250);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}