I'm trying to pass the arguments from a jar file(samplecode.jar) to a Perl script using
ProcessBuilder pb=new ProcessBuilder("perl", "C:\\Xampp\\perl\\bin\\echocopy.pl", "10");
and in Perl file retrieving the value and passing the value to a jar file(Monitor.jar).The Perl code is
while(my $accNo = <STDIN>){
if(length($accNo) > 1){
$accNo = substr $accNo, 0 , (length($accNo) - 1);
print "value received is $accNo";
my $cmd = "";
my $res = "";
$cmd = "java -jar C:\Newfolder1\Monitor.jar \"$accNo\"";
print "Execution Success";
$res = qx/$cmd/;
print "$res\n";
} else {
printf "1\n";
}
}
The Monitor.jar code is
import java.io.FileWriter;
public class Verifys {
public static void main(String[] args) {
try {
String n = args[0];
System.out.printf("the received value is:\n", n);
FileWriter myWriter = new FileWriter("C:\\Newfolder1\\filename1.txt");
myWriter.write(n);
myWriter.close();
System.out.println("Successfully wrote to the file.");
} catch (Exception e) {
System.out.println("Not Successfully wrote to the file.");
e.printStackTrace();
}
}
}
and in Monitor.jar I'm trying to receive that value and store it in a file but I'm unable to do it.Could anyone please help me out.