I am creating a GUI in java that requires a set of commands to be run through the command line one after the other in the background after the user selects a file and clicks a button in the GUI. The commands to be executed will include the path of the file. How can I get the command line to run in the background with a set of commands after the user selects a button?
The GUI as of now only includes the file chooser.
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileSystemView;
public class GUIProject {
public static void main(String[] args) {
JFileChooser jfc = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());
int returnValue = jfc.showOpenDialog(null);
// int returnValue = jfc.showSaveDialog(null);
if (returnValue == JFileChooser.APPROVE_OPTION) {
File selectedFile = jfc.getSelectedFile();
System.out.println(selectedFile.getAbsolutePath()); //Instead of printing send it to cmd and perform more commands
}
}
}