This code works for me, but when I add the program bajador.exe, inside my jar, in "/parseadores/bajador.exe", and change those lines to call the .exe from inside the jar, it does not work. Could someone help me how should I do it? I am using the windows 10 operating system at all times, and the eclipse editor. Thanks.
public void crearVideoEnCarpeta(){
String portaPapeles = "";
try {
portaPapeles = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
} catch (HeadlessException | UnsupportedFlavorException | IOException e2) {
e2.printStackTrace();
}
// aqui obtengo la ruta de donde se esta ejecutando el programa
String rutaDondeSeEjecutaProgramaDescargador = new File(".").getAbsolutePath();
// le quito el ultimo . y ultima barra \, osea los dos ultimos elementos, restandole -2 a su longitud
rutaDondeSeEjecutaProgramaDescargador = rutaDondeSeEjecutaProgramaDescargador.substring(0, (rutaDondeSeEjecutaProgramaDescargador.length() - 2));
String rutaDondeCopiare = rutaDondeSeEjecutaProgramaDescargador + "\carpeta" + "\videos";
// antigua linea:
//String rutaDondeDebeDeEstar = rutaDondeSeEjecutaProgramaDescargador + "\carpeta\bajador.exe " + "-o " + "\"" + rutaDondeCopiare + "\%(title)s-%(id)s.%(ext)s\"";
// nueva linea:
String rutaDondeDebeDeEstarNueva = "/parseadores/bajador.exe" + " " + "-o " + "\"" + rutaDondeCopiare + "\%(title)s-%(id)s.%(ext)s\"";
try {
String cmd2 = rutaDondeDebeDeEstarNueva + " " + portaPapeles;
Runtime.getRuntime().exec(cmd2);
JOptionPane.showMessageDialog(null, cmd2);
UIManager.put("OptionPane.minimumSize", new Dimension(262, 90));
} catch (IOException ioe) {
System.out.println(ioe);
}
}