It sounds a reasonable design. You would write something like this.
import java.lang.Runtime;
int width = 99;
try {
Runtime runt = Runtime.getRuntime()
Process proc = runt.exec('/usr/bin/perl', '/path/to/myperl.pl', Integer.toString(width));
proc.waitFor();
}
catch (Exception ioe) {
ioe.printStackTrace();
}
Of course you'll have to adjust /usr/bin/perl
to where your own perl exeutable really is, or you could invoke the shell to get it to search the path by using
runt.exec( '/bin/bash', '-c', 'perl', '/path/to/myperl.pl', Integer.toString(width) );
As for how to get the image back to the client, you don't say much about how your Perl program works, but either you tell it where to write the file or it decides for itself and tells you where it's put it afterwards
If it's the former, then you presumably pass the path on the command line, so you just have to extend the call to runt.exec
above to pass another parameter
If it's the latter, then presumably the program prints to STDOUT where it has put the new file, and you need to read that stream from your Java code to collect the information. That would look like this in place of the proc.waitFor()
call
import java.io.*;
BufferedReader inp = new BufferedReader(
new InputStreamReader(proc.getInputStream())
);
while ( ( line = inp.readLine() ) != null ) {
// Process output of Perl code to get file location
}