I have the following code
Process p = new ProcessBuilder("D:\\Encryption.exe", "D:\\Cat-hd-
wallpapers_remain_both2.jpg").start();
This code can run fine but instead of declaring "D:\Cat-hd- wallpapers_remain_both2.jpg" this in my code I want to use file chooser for selecting file. I use the following code but still not working.
imageUpload.setOnMouseClicked(event -> {
FileChooser fileChooser=new FileChooser();
fileChooser.setInitialDirectory(new File("c:\\"));
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("JPG Images","*.jpg"),
new FileChooser.ExtensionFilter("JPEG Images","*.jpeg"),
new FileChooser.ExtensionFilter("PNG Images","*.png"));
File file=fileChooser.showOpenDialog(null);
if (file!=null){
try {
imageUpload.setImage(new Image(file.toURI().toURL().toString()));
Process p = new ProcessBuilder("D:\\Encryption.exe",file.getAbsoluteFile().getAbsolutePath()).start();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException ex) {
Logger.getLogger(decriptImageController.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
it throws the following error
CreateProcess error=2, The system cannot find the file specified
Can you please help me to find out the problem.Thanks in advanced.