I run a file .exe
(for sending images) from java
which can pull different output codes depending on the error, this is my class:
public static int SendImg(String ip, int puerto, String rutaIMG, String tipo) {
Process p = null;
try {
Runtime aplicacion = Runtime.getRuntime();
p = aplicacion.exec("C:\SendImg.exe " + ip + " " + puerto + " " + '"' + rutaIMG + '"' + " " + tipo);
} catch (IOException ex) {
return p.exitValue();
}
return p.exitValue();
}
And so I call it, the problem is that it always returns 0
regardless of whether the transfer failed or not:
int res = Conector.SendImg(cIP.getSelectedItem().toString(), puerto, tRuta.getText(), cbTipo.getSelectedItem().toString());
if (res == 0) {
JOptionPane.showMessageDialog(null, "Imagen enviada correctamente");
}
if (res == 1) {
JOptionPane.showMessageDialog(null, "Error enviando imagen producto A");
}
if (res == 2) {
JOptionPane.showMessageDialog(null, "Error enviando imagen producto B");
}
if (res == 3) {
JOptionPane.showMessageDialog(null, "Error enviando imagen Splash");
}
if (res == 6) {
JOptionPane.showMessageDialog(null, "Parametro no valido sTypeData");
}
if (res == 7) {
JOptionPane.showMessageDialog(null, "No existe la imagen");
}
If it is correct, the image is sent, if it is not, the image is not sent but I also get zero, is there any other way to get the output code?
EDIT: ZIP file with the executable; SendImg.exe