I'm no java whiz, so maybe that's why I find your java syntax to be pretty confusing:
Process p = Runtime.getRuntime().exec("c:/perl.exe" C:/CreateER.pl
"Please \n ignore \n my friend");
Why no comma after "c:/perl.exe", or after C:/CreateER.pl? For that matter, why does the java code use C:/CreateER.perl, whereas your working shell command ("running it directly") has C:/scripts2/CreateER.pl ?
I gather that java is interpreting the "\n" in the last arg, and outputting actual line-feed characters in their place, which I would expect to make a mess of some sort.
I don't know if this is doable for you, but the next thing I would try would be to open the perl process as a pipeline file handle, and print to that file handle the string that contains any given number of line-feed characters, so that perl script reads this from its STDIN (rather than getting it in @ARGV).
I don't know how that would look in java (or whether you can do it at all) -- it would be done like this in perl:
my $pid = open( PROC, "|-", "c:/perl.exe c:/scripts2/CreateER.pl" )
or die "cannot launch perl process: $!";
print PROC "anything\nyou\nwant\nto\ndo\n";
close PROC;
Another possibility: print the multi-line string in question to a file (surely java can do that), and then have the "exec()" call run the perl script with the name of the file, so perl can read the lines with while(<>) or whatever.
Or, maybe try just making the string look like this in java:
Please \\n ignore \\n my friend
So that the string ends up being a single line with literal "backslash""n" sequences in it, which perl can then interpret as intended.
UPDATE: It sounds like you haven't tried one of the other ideas in my initial reply: before passing your multi-line string to the exec call as a command-line arg for your perl script, convert the "\n" characters (or literal "backslash""n" sequences) to something safe and innocuous (like "=:=" or anything that won't ever be confused with other stuff in the string), and modify the perl script so it knows to convert this back to "\n" when it gets the string out of @ARGV. |