I have a big perl script I want to start through my java program. I have extensively searched on the web for all the possibilities and they did not help me anything further.
I made the following java script for starting my commandline perl script.
try {
String[] command = {"perl", "C:\\Users\\Rick\\Documents\\Perl\\InDelSub_finder_v0.2.0.pl"};//System.getProperty("user.dir")+"\\src\\InDelSub_finder_v0.2.0.pl", "-h"};
String[] comm = {"-h"};
System.out.println(Arrays.toString(command));
System.out.println(Arrays.toString(comm));
Process p = Runtime.getRuntime().exec(command, comm);
p.waitFor();
try{
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
while ((line = in.readLine())!=null){
System.out.println(line);
}
}catch(IOException e2){
e2.printStackTrace();
}
System.out.println("exitValue = " + p.waitFor());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
I tried to use a String[]
and a String
to give to the exec()
, but in the end both did not work, it keeps giving me a exitValue() = 255
. I also tried (as you can see in the commented away section) that I tried multiple ways to access the right file, but this is not what is going wrong. I think it has something to do with that it can not open the program for some reason.
Could anyone please help me with this? I am really lost in this one and I need it to continue my work.
Thank you very much for your time.