How to choose a program to run?-Collection of common programming errors

I have this code:

import javax.swing.JOptionPane;

class OpenProgram {

    public static void main(String[] args) throws Exception {

        // opens the JOptionPane
        String path = JOptionPane
                .showInputDialog("Type the path to a program or other file(forward slashes)");

        //runs the program
        Process run = Runtime.getRuntime().exec("\"" + path);
        System.out.println("Program Opened!");
        run.waitFor();
    }
}

It is supposed to bring up a JOptionPane and have the user type in the path to a program, then run the specified program, but when I test it and press OK on the JOptionPane, it says it couldn’t run it. Any help?